鍍金池/ 問答/Java  HTML/ vue 數(shù)組動態(tài)的添加值,但是值已經(jīng)添加上了,但是沒法渲染

vue 數(shù)組動態(tài)的添加值,但是值已經(jīng)添加上了,但是沒法渲染

vue 數(shù)組動態(tài)的添加值name,name值已經(jīng)添加上了,但是沒法渲染。是否是同步異步的問題,或者重新加載數(shù)據(jù),我要如何編寫

            <div>
                <legend>配方信息</legend>
                <div class="layui-inline" v-for="p in priceList">
                    <label class="layui-form-label">{{p.name}}</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        標準量:
                        <input type="text" name="model" class="layui-input" v-model="p.std">
                    </div>
                    <div class="layui-input-inline" style="width: 100px;">
                        最大量:
                        <input type="text" name="model" class="layui-input" v-model="p.max">
                    </div>
                    <div class="layui-input-inline" style="width: 100px;">
                        最小量:
                        <input type="text" name="model" class="layui-input" v-model="p.min">
                    </div>
                </div>
            </div>
            
            <script>
                    var terminalForm = new Vue({
            el: '#terminalForm',
            data: {
                t: data ? data : {},
                priceList: [],
                suee: false
            },
            create: function () {
                var that = this
                that.priceList = that.t.recipes
                $.get('api/product/list_ingredient').then(function (res) {
                    var recipes = that.priceList;
                    var priceName = res.data;
                    for (var i in recipes) {
                        for (var j in priceName) {
                            if (recipes[i].ingredientId == priceName[j].id) {
                                recipes[i].name = priceName[j].name;
                            }
                        }
                    }
                })

                console.log(that.priceList)
                that.suee = true
            },
        });
            
            </script>
回答
編輯回答
有你在
由于 JavaScript 的限制,Vue 不能檢測以下變動的數(shù)組:
當你利用索引直接設(shè)置一個項時,例如:vm.items[indexOfItem] = newValue
當你修改數(shù)組的長度時,例如:vm.items.length = newLength

利用這些 函數(shù)進行操作
push()
pop()
shift()
unshift()
splice()
sort()
reverse()
或者對list 重新賦值 即可 list = newList
或者 list.splice(0, list.length -1) 然后 重新 push 一遍

再看看 vue 官網(wǎng) 列表渲染吧

2017年3月1日 17:09
編輯回答
尕筱澄

https://cn.vuejs.org/v2/api/#...

用Vue.set( target, key, value )設(shè)置動態(tài)屬性值

2017年7月3日 15:37
編輯回答
傻丟丟

Object.assign({},)

2017年12月14日 11:05