Svelte 获取当前 svelte 文件的所有属性

Svelte get all properties on current svelte file

如何获取当前 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>

您可以为此使用 $$props,它将 return 传递给组件的所有属性。