vue 控制台 报错Cannot read property ‘value‘ of undefined

  • Post author:
  • Post category:vue


		<el-form-item v-for="(item,i) in info" :key="i" :label="item.name">
              <el-input placeholder v-model="item.value">
                <template slot="append">{{item.danwei}}</template>
              </el-input>
        </el-form-item>
info:[
     {id:'1',name:'农户总数',value:'',danwei:'户'},  //0
     {id:'2',name:'农村劳动力人口',value:'',danwei:'人'},  //1
     {id:'3',name:'规模种植主体数量',value:'',danwei:'个'}, //2
     {id:'4',name:'规模种植总面积',value:'',danwei:'亩'},  //3
     {id:'5',name:'粮食作物面积',value:'',danwei:'亩'},
     {id:'6',name:'经济作物面积',value:'',danwei:'亩'},
     {id:'7',name:'蔬菜瓜果面积',value:'',danwei:'亩'},
]
 baocun(){
       var _this = this;
      _this.$axios.post("http://nongye.philisensedev.com/rest/planting/"+_this.proid+"/"+_this.taskid+"/planting/add",
      {
	        "gg01": _this.info[54]['value'],  
	        "gy01": _this.info[56]['value'],  
	        "gy02": _this.info[57]['value'],     
	        "gy03": _this.info[58]['value'],
	        "gy04": _this.info[59]['value'],
        }
}).then(function(res){
          console.log(res);
          _this.$message(res.data.message);
  });

vue 控制台 报错Cannot read property ‘value’ of undefined

解决办法:

一开始info数组没有添加id属性,控制台报错

之后添加id属性,问题解决,不明白为什么?



版权声明:本文为qq_43907534原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。