Vue动态添加变量给变量赋值
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Vue动态添加变量给变量赋值</title><script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script><
·
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue动态添加变量给变量赋值</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div id="app">
{{ info }}
</div>
<script type = "text/javascript">
new Vue({
el: '#app',
data () {
return {
info: '动态添加变量给变量赋值',
parnum0:'',
parnum1:'',
parnum2:'',
parnum3:'',
}
},
mounted () {
for(let i =0;i<4;i++){
this['parnum'+i]=i
}
console.log(this.parnum0)
}
})
</script>
</body>
</html>
更多推荐
已为社区贡献7条内容
所有评论(0)