先給大家展示下效果圖,如果感覺(jué)不錯(cuò),請(qǐng)參考實(shí)現(xiàn)代碼
1、先獲取門(mén)店下的所有菜品類型、菜品名稱、菜品id(list),也就是最大數(shù)據(jù)量
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、獲取該菜譜已經(jīng)擁有(勾選了哪些)的菜品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頁(yè)面使用vue對(duì)兩數(shù)據(jù)進(jìn)行對(duì)比,菜品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>
總結(jié)
以上所述是小編給大家介紹的vue.js做一個(gè)簡(jiǎn)單的編輯菜譜功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com