如何获取当前 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>
Run Code Online (Sandbox Code Playgroud)
使用者whatever.svelte
<script>
import Foo from `./Component1.svelte`
</script>
<Foo x="1" y="abc">test</Foo>
Run Code Online (Sandbox Code Playgroud)
您可以使用$$props
它,它将返回传递给组件的所有属性。
归档时间: |
|
查看次数: |
1070 次 |
最近记录: |