如下所示:
<el-checkbox v-for="(item) in jurisdictionContent" :label="item.id" :key="item.id" class="checkboxMargin"> <span>{{item.value}}{{item.checked}}</span> </el-checkbox> handleJurisdiction(index, row) {//獲取權(quán)限 this.selectedCheck=[]; let me = this; this.jurisdiction = true; this.roleId = row.id; this.$http.get("/role/resources", { params: {roleId: this.roleId} }, { emulateJSON: true }).then((response) => { me.jurisdictionContent = response.body; me.jurisdictionContent.forEach(function (c) { if(c['checked']){ me.selectedCheck.push(c.id); } }) console.log(this.selectedCheck) })vue 中標(biāo)簽里循環(huán)使用v-for,方法里面循環(huán)使用forEach。
以上這篇vue forEach循環(huán)數(shù)組拿到自己想要的數(shù)據(jù)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持錯新站長站。
新聞熱點
疑難解答
圖片精選