optiman
optiman

Reputation: 93

Declare typescript interface props in vue.js component

I want to define vue component props with in a single object in typescript.

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;

    .....
}

I can do this like above in class based component.

But how can I do this in component using Vue.extend()?

Upvotes: 2

Views: 922

Answers (1)

avimimoun
avimimoun

Reputation: 951

Try this syntax

props: {
  foo: {
    type: Object as () => IFoo
  }
}

Upvotes: 1

Related Questions