vue-property-decorator @prop 如何定义 Array

'use strict'import Vue from 'vue'import { Prop, Watch } from 'vue-property-decorator'interface ITabs {
    name: string
    value: string}export default class extends Vue {    @Prop({        type: Array,        default() {            return []
        }
    })    public tabs!: ITabs[] // TS2416}
TS2416: Property 'tabs' in type 'default' is not assignable to the
same property in base type 'object & Record<never,any> & Vue'. Type
'ITabs[]' is not assignable totype '{ name: ""; value: ""; }[] |
undefined'. Type 'ITabs[]' is not assignable to type '{ name: "";
value: ""; }[]'. Type 'ITabs' is not assignable to type '{ name: "";
value: ""; }'. Types of property 'name' are incompatible. Type
'string' is not assignable to type '""'.


江户川乱折腾
浏览 4143回答 1
1回答

噜噜哒

export&nbsp;default&nbsp;class&nbsp;extends&nbsp;Vue&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;@Prop({&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type:&nbsp;Array,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;[] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;tabs&nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript