如何获取当前svelte文件的所有属性?
例如,这个Component1.svelte
<script>
let x = '';
let y = '';
let z = '';
onMount(function(){
console.log( what? );
// need to print x, y, and z which set by other code
// that using/importing this file
// without defining one by one, was there such property?
});
</script>
<span>{x}</span>
<div>{y}</div>
<p>{z}</p>由whatever.svelte使用
<script>
import Foo from `./Component1.svelte`
</script>
<Foo x="1" y="abc">test</Foo>发布于 2020-10-07 15:32:06
您可以为此使用$$props,它将返回传递给组件的所有属性。
https://stackoverflow.com/questions/64247315
复制相似问题