2

タイプスクリプトの単一のオブジェクトで vue コンポーネントの小道具を定義したい。

import {Component, Prop, Vue} from 'vue-property-decorator'

export class Props extends Vue
{
  classElement :string
}

@Component
export default class Menu extends Vue<Props>
{
    public props :Props;

    .....
}

クラスベースのコンポーネントで上記のようにこれを行うことができます。

しかし、Vue.extend() を使用してコンポーネントでこれを行うにはどうすればよいですか?

4

1 に答える 1

1

この構文を試してください

props: {
  foo: {
    type: Object as () => IFoo
  }
}
于 2021-05-24T01:15:41.113 に答える