这是:
properties: {
myObject: {
type: Object,
value: {
parameters: {
type: Array,
value: []
},
color: {
type: String,
value: 'red'
}
}
}
}
不起作用,因为你想“定义”
parameters
和
color
就好像它们是财产一样
myObject
的值),但实际上您正在指定对象文本
{
parameters: {
type: Array,
value: []
},
color: {
type: String,
value: 'red'
}
}
作为价值
我的对象
财产。所以
myObject.parameters
在这种情况下
Object
而不是
Array
因此
this.push
失败。
通过定义尝试
我的对象
这种方式:
properties: {
myObject: { // Define properties at this level only
type: Object,
value: {
parameters: [], // Parameters is initially an empty array
color: 'red',
}
}
}