我有一个页面,其中字段名称是数组类型。
eg. mapping[map][email_address][type]
现在在Vue中,我想设置默认值,我正在执行以下操作
new Vue({
el: '#configure',
data: {
mapping: {
map: {
email_address: {
type: 'incoming_field'
}
}
}
}
})
但我在控制台中收到错误
[Vue warn]: Property or method "map" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
vue.js:569 [Vue warn]: Property or method "email_address" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
vue.js:569 [Vue warn]: Error in render function:
(found in <Root>)
在Vuejs中处理此类字段名称的最佳方法是什么?
答案 0 :(得分:0)
与你的代码一样,你必须这样做:
fdr = objMatches.Item(0)
If CaseFolders.Folders(fdr) Is Nothing Then CaseFolders.Folders.Add fdr
或
mapping['map']['email_address']['type']
答案 1 :(得分:0)
您应该重新考虑您的数据,以便没有这么多嵌套对象。
如果要在对象中直接设置属性,最好使用Vue.set来确保you do not break reactivity。这样做可以节省数小时的头痛,试图找出出现问题的地方。
Vue.set(mapping.map.email_address, 'type', value_to_set)