我正在使用Vuejs3构建一个简单的文章配置器.
让我们定义一个复杂对象:
const article = reactive({
code: 'code',
specs: {
type: { text: 'description type', value:'mytype'} ,
prop1: { text: 'description prop1', value: 'myprop1' },
prop2: { text: 'description prop1', value: 'myprop1' },
},
dimensions: { base: 10, height: 20}
})
让我们看看每一篇文章.规格:
<li v-for="(value, propertyName, index) in article.specs">
{{ propertyName }}: {{ value }} ({{ index }})
</li>
结果:
type: { "text": "description type", "value": "mytype" } (0)
prop1: { "text": "description prop1", "value": "myprop1" } (1)
prop2: { "text": "description prop1", "value": "myprop1" } (2)
但我如何才能提取财产的"价值"才能得到.
type: description type
prop1: description prop1
prop2: description prop1
我试过了:
{{ propertyName }}: {{ value[text] }} ({{ index }})
但会导致空值:
type: (0)
prop1: (1)
prop2: (2)