課程
/前端開發
/Vue.js
/vue2.5入門
刪除的方法一直顯示未在實例中定義
2019-03-20
源自:vue2.5入門 4-2
正在回答
你這個<list-item
????????? ?@delete="amputate"? ?這個@delete是子組件內傳出的函數? methods: {
????????????????????????????????????????????????????????????????????????????????????????????????????????????子組件綁定刪除事件
????????????????????????????????????????????????????????????????????????????????????????????????????????????handerDetlete() {
????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????this.$emit("delete", this.index);
????????????????????????????????????????????????????????????????????????????????????????????????????????????????其中“detele”是子組件傳遞給父組件的事件也就是綁定在 <list-item @delete="amputale" :index="index">中的 @delete監聽事件
????????????????????????????????????????????????????????????????????????????????????????????????????????????????this.index是子組件傳遞給父組件的參數?
????????????????????????????????????????????????????????????????????????????????????????????????????????????}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
????????????>
父組件綁定(調用子組件刪除)
methods: {
? ? ?amputale(index) {
????????// index?是從?this.$emit("delete", this.index);?中 this.index傳出的值
????????this.list.splice(index, 1);
? ?}
}
盛夏黃昏 提問者
好吧真的不知道取什么名字 回復 盛夏黃昏 提問者
盛夏黃昏 提問者 回復 好吧真的不知道取什么名字
yuyan 回復 盛夏黃昏 提問者
舉報
快速理解Vue編程理念上手Vue2.0開發。
1 回答方法未定義
4 回答方法定義在哪里
1 回答“Cannot read property 'splice' of undefined” 為什么會說splice未定義?
3 回答組件定義的問題
2 回答vue沒有定義怎么解決
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2019-03-21
你這個<list-item
????????? ?@delete="amputate"? ?這個@delete是子組件內傳出的函數? methods: {
????????????????????????????????????????????????????????????????????????????????????????????????????????????子組件綁定刪除事件
????????????????????????????????????????????????????????????????????????????????????????????????????????????handerDetlete() {
????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????this.$emit("delete", this.index);
????????????????????????????????????????????????????????????????????????????????????????????????????????????????其中“detele”是子組件傳遞給父組件的事件也就是綁定在 <list-item @delete="amputale" :index="index">中的 @delete監聽事件
????????????????????????????????????????????????????????????????????????????????????????????????????????????????this.index是子組件傳遞給父組件的參數?
????????????????????????????????????????????????????????????????????????????????????????????????????????????}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
????????????>
父組件綁定(調用子組件刪除)
methods: {
? ? ?amputale(index) {
????????// index?是從?this.$emit("delete", this.index);?中 this.index傳出的值
????????this.list.splice(index, 1);
? ?}
}