<!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>

 

Logo

前往低代码交流专区

更多推荐