鍍金池/ 問答/Linux  HTML/ v-for無法循環(huán)遍歷

v-for無法循環(huán)遍歷

v-for無法循環(huán)遍歷出值

代碼:

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

圖片描述

回答
編輯回答
替身

今天我也遇到了這個問題,我是判斷數(shù)組的長度是否大于0,因為vue和layui的渲染速度不一樣

2017年11月7日 05:47
編輯回答
眼雜

是不是id問題
clipboard.png

2017年1月14日 17:06
編輯回答
朕略萌

首先,你data里面那個t值報錯了,后面的data根本不存在,先把這行刪了
然后,主要原因是上面的id跟下邊的el沒對上

2018年9月21日 20:19