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

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

有一個問題,我發(fā)現(xiàn)如果input框里什么也不輸入時點擊提交仍然能創(chuàng)建一個空的li出來,請問怎么能檢測如果input中的值為空不創(chuàng)建li呢

<div class="root">

<input v-model="inputValue" />

<button @click="handle">提交</button>

<input type="button" @click="del" value="刪除" />

<ul>

<li v-for="(item,index) of list" :key = item>{{item}}</li>

</ul>

</div>

<script>

new Vue({

el:'.root',

data:{

inputValue:'',

list:[]

},

methods:{

handle:function(){

this.list.push(this.inputValue);

this.inputValue = '';

},

del:function(){

this.list.pop(this.inputValue);

}

}

})

</script>



正在回答

3 回答

methods:?{
????handleSubmit:?function()?{
????????if(this.inputValue?!=?""){
????????????this.list.push(this.inputValue);
????????????}
????????}
????}


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

如何讓列表為空不顯示列表,如果沒有判斷,會有一個空列表https://img1.sycdn.imooc.com//5ba9b3170001035206200188.jpg

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

在this.list.push(this.inputValue);加一個if(this.inputValue!="")判斷就行了


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

舉報

0/150
提交
取消

有一個問題,我發(fā)現(xiàn)如果input框里什么也不輸入時點擊提交仍然能創(chuàng)建一個空的li出來,請問怎么能檢測如果input中的值為空不創(chuàng)建li呢

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

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

幫助反饋 APP下載

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

公眾號

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