vue中接口循环v-for 里面的input需要 v-model=“pay” pay不是item的元素 如何一一对应?

html

https://img2.mukewang.com/5ac19d860001f5af13040555.jpg

效果图  v-model的属性不是item中的

https://img3.mukewang.com/5ac19d830001db9208750628.jpg

js:

https://img4.mukewang.com/5ac19d840001996613240818.jpg

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)

            }

         }

    })



感谢大神们指点^^^^^

慕瓜4450240
浏览 6682回答 1
1回答

夜舞暗澜

如果你打算同时显示,那么就必须设置成一一对应的。一种方式是给传入的items加一层处理,每个item里加一个pay;另一种方式是将pay写成数组,然后绑定对应值:v-model="pay[index]"
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Vue.js