[英]Dynamic variable substitution in vuejs
我有以下动态变量
{{地区}}
可以等于北,南,东或西。
我想用它从我的数据对象中提取变量
我试过了
{{#region.copy}}
这有可能吗
data: function() {
return {
north : {
copy: "this is the north copy"
},
south : {
copy: "this is the north copy"
}
}
您可以将北,南,东和西放置在对象地理区域中。 在geo中,您可以通过geo[region].copy
访问您的区域。 如果region === south
,将导致geo.south.copy
编辑:在计算变量中,您也可以使用this[region].copy
而不是地理位置包裹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.