第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

handleclick 哪兒報錯

<!DOCTYPE html>
<html>
?? ?<head>
?? ??? ?<meta charset="utf-8">
?? ??? ?<title></title>
?? ??? ?<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
?? ?</head>
?? ?<body>
?? ??? ?<div id="root">
?? ??? ??? ?<div>
?? ??? ??? ??? ?<input v-model="inputValue" />
?? ??? ??? ??? ?<button @click="handleSubmit">提交</button>
?? ??? ??? ?</div>
?? ??? ??? ?<ul>
?? ??? ??? ??? ?<!-- <li v-for="(item,index) of list" :key="index"> -->
?? ??? ??? ??? ?<!-- ?? ?{{item}} -->
?? ??? ??? ??? ?<todo-item v-for="(item,index) of list"
?? ??? ??? ??? ?:key="index"
?? ??? ??? ??? ?:content='item'
?? ??? ??? ??? ?:index="index"
?? ??? ??? ??? ?@delete='handleDelete'????????? 監(jiān)聽handleDelete事件
?? ??? ??? ??? ?>
?? ??? ??? ??? ?</todo-item>
?? ??? ??? ??? ?<!-- </li> -->
?? ??? ??? ?</ul>
?? ??? ?</div>
?? ??? ?<script>
?? ??? ??? ?Vue.component('todo-item',{
?? ??? ??? ??? ?props: ['content',index],
?? ??? ??? ??? ?template: '<li @click='handleClick'>{{content}}</li>',
?? ??? ??? ??? ?methods: handleClick: function(){
?? ??? ??? ??? ??? ? this.$emit('delete',this.index)
?? ??? ??? ??? ??? ? }
?? ??? ??? ??? ?}
?? ??? ??? ??? ?
?? ??? ??? ?})
?? ??? ??? ?
?? ??? ??? ?new Vue({
?? ??? ??? ??? ?el:"#root",
?? ??? ??? ??? ?data:{
?? ??? ??? ??? ??? ?inputValue: "",
?? ??? ??? ??? ??? ?list: []
?? ??? ??? ??? ?},
?? ??? ??? ??? ?methods: {
?? ??? ??? ??? ??? ?handleSubmit: function(index){
?? ??? ??? ??? ??? ??? ?this.list.push(this.inputValue)
?? ??? ??? ??? ??? ??? ?this.inputValue = ''
?? ??? ??? ??? ?},
?? ??? ??? ??? ?handleDelete:function(){
?? ??? ??? ??? ??? ?this.list.splice(index,1)
?? ??? ??? ??? ?}
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?})
?? ??? ?</script>
?? ?</body>
</html>

正在回答

6 回答

http://img1.sycdn.imooc.com//5ff821b30001405206040084.jpg

我的理解,組件中methods是個對象,而不是一個函數(shù),畢竟method帶有s哦

0 回復(fù) 有任何疑惑可以回復(fù)我~

http://img1.sycdn.imooc.com//5da976520001e48504460209.jpg這里應(yīng)該寫成methode:{handleClick:function(){........}}

0 回復(fù) 有任何疑惑可以回復(fù)我~

應(yīng)該用雙引號 @click="HandClick"index? ?而且上面漏了單引號? props:['content','index']

0 回復(fù) 有任何疑惑可以回復(fù)我~

methods:{

handleSumbit:function(){

this.list.push(this.inputValue);

this.inputValue = '';

},

handleDelete:function(index){

this.list.splice(index,1);

}

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

https://img1.sycdn.imooc.com//5d2c1ba000014f9906870308.jpg

不是這個問題


0 回復(fù) 有任何疑惑可以回復(fù)我~

你的method方法,掉了參數(shù)index,應(yīng)該為

handleDelete:function(index){ ? ? ? ? ? ?

this.list.splice(index,1)? ? ? ??

}


1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

handleclick 哪兒報錯

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號