v-for无法循环遍历

v-for无法循环遍历出值

代码:

<fieldset class="layui-elem-field" id="priceForm">
            <legend>配方信息</legend>
            <div class="layui-inline" v-for="p in priceList">
                <label class="layui-form-label">{{p.id}}</label>
                <div class="layui-input-inline" style="width: 100px;">
                    标准值:
                    <input type="text" name="id" v-model="p.std" autocomplete="off" class="layui-input">
                </div>
            </div>
        </fieldset>
        
        
 <script>
var terminalForm = new Vue({
            el: '#terminalForm',
            data: {
                t: data ? data : {},
                priceList: [{
                        "id": 1,
                        "menuId": 1,
                        "productId": 1,
                        "ingredientId": 2,
                        "ingredient": null,
                        "menuTitle": null,
                        "logo": null,
                        "remark": "0",
                        "sn": null,
                        "std": 220,
                        "min": 180,
                        "max": 260,
                        "level": 5,
                        "delay": 0,
                        "water": 130,
                        "waterType": 1,
                        "sort": 1
                    },
                    {
                        "id": 2,
                        "menuId": 1,
                        "productId": 1,
                        "ingredientId": 6,
                        "ingredient": null,
                        "menuTitle": null,
                        "logo": null,
                        "remark": "0",
                        "sn": null,
                        "std": 50,
                        "min": 30,
                        "max": 70,
                        "level": 6,
                        "delay": 0,
                        "water": 30,
                        "waterType": 1,
                        "sort": 2
                    },
                    {
                        "id": 3,
                        "menuId": 1,
                        "productId": 1,
                        "ingredientId": 1,
                        "ingredient": null,
                        "menuTitle": null,
                        "logo": null,
                        "remark": "0",
                        "sn": null,
                        "std": 120,
                        "min": 110,
                        "max": 130,
                        "level": 5,
                        "delay": 0,
                        "water": 90,
                        "waterType": 1,
                        "sort": 3
                    }
                ]
            },
      });
</script>    

图片描述

阅读 5.1k
3 个回答

是不是id问题
clipboard.png

首先,你data里面那个t值报错了,后面的data根本不存在,先把这行删了
然后,主要原因是上面的id跟下边的el没对上

新手上路,请多包涵

今天我也遇到了这个问题,我是判断数组的长度是否大于0,因为vue和layui的渲染速度不一样

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题