先給大家展示下效果圖,如果感覺不錯,請參考實現代碼
1、先獲取門店下的所有菜品類型、菜品名稱、菜品id(list),也就是最大數據量
this.$http.post(ceshiApi+'getCyFoodAndFoodTypeForShopId',{shopId:this.shopId},{emulateJSON:true,credentials: true}).then(function(res){ if(res.data.type=='success'){ this.foodList = res.data.data.cyFoodTypeList; } });
2、獲取該菜譜已經擁有(勾選了哪些)的菜品id(list)
this.$http.post(ceshiApi+'getCyMenuFoodByMenuId',{'cyMenuId': id},{emulateJSON:true,credentials: true}).then(function(res){ if(res.data.type=='success'){ let data = res.data.data; let list = []; for(let i = 0; i < data.length; i++) { list.push(data[i].foodDefineId); } this.foodListId = list; }else { alertErrors(res.data.message); } });
3、在html頁面使用vue對兩數據進行對比,菜品id相同就打勾
<div class="modal-body"> <div class="scroll_name "> <div class="newRecipe" style="overflow-y: scroll;height: 410px;"> <div v-for="item in foodList" style="display: flex;flex-wrap: wrap;"> <label style="margin-right: 20px;">{{ item.name }}</label> <div class="food-list"> <div v-for="food in item.cyFoodDefineList"> <label> <input class="ace check_son" type="checkbox" :value="food.id" v-model="foodListId"> <span class="lbl">{{ food.name }}</span> </label> </div> </div> </div> </div> </div> </div>
總結
以上所述是小編給大家介紹的vue.js做一個簡單的編輯菜譜功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com