vue中接口循环v-for 里面的input需要 v-model=“pay” pay不是it
html
效果图 v-model的属性不是item中的
js:
var vm = new Vue({
el:'#mygifiTCdiv',
data:{
items:[
// {pay:"1"},
],
pay:[],//pay:''因为是多个inout 所以是数组的形式
},
created: function(){
this.getRoute();
},
//在 methods中定义方法函数
methods: {
getRoute: function () {
var that = this;
var url= path+"/packageProduct/selectPackageProductByAddressIdAndType";
this.$http.post('http://localhost:8080/ArtAppInst2/packageProduct/selectPackageProductByAddressIdAndType',{
"addressId":storageAddressId,
"token":token,
"packageType":8,
},
{
emulateJSON:true
}).then(function(response){
console.log(response.data.msg);
that.data = response.data.msg;
that.items = response.data.body.packageProducts;
console.log(that.items);
},function(response){
alert(response.msg)
});
},
buyPackageBtn:function(id){
alert(id)
}
}
})
感谢大神们指点^^^^^ |
免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。
版权声明:作者保留权利,不代表本站立场。
|
|
|
|
|
|
|
如果你打算同时显示,那么就必须设置成一一对应的。
一种方式是给传入的items加一层处理,每个item里加一个pay;
另一种方式是将pay写成数组,然后绑定对应值:v-model="pay[index]" |
|
|
|
|
|
|
|