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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

不用組件拆分的方式,完成todolist功能

不用組件拆分的方式,怎樣實(shí)現(xiàn)todolist功能?有哪位小伙伴試過(guò)嗎?分享一下代碼?

正在回答

2 回答

<!DOCTYPE?html><html><head>	<meta?charset="utf-8">	<title>todo</title>	<script?type="text/javascript"?src="./vue.js"></script></head><body>	<div?id="app">		<input?type="text"?v-model="event">		<button?@click="submit">提交</button>		<!--?不使用組件?-->		<ul>			<li?v-for="(item,?index)?in?list"?:key="index"?:data-id="index"?@click="del">{{item}}</li>?		</ul>					<!--?使用全局組件?-->		<!--?<ul>			<todo-item-qj?v-for="(item,?index)?in?list"?				:key="index"?				:content="item"?				:prex="index"				@delete="handleDelete"				>			</todo-item-qj>		</ul>?-->	</div>	<script?type="text/javascript">		//?全局組件		Vue.component('todo-item-qj',?{			props:?['content',?'prex'],			template:?'<li?@click="handleClick">{{prex}}?-?{{content}}</li>',			methods:?{				handleClick:?function(){					this.$emit('delete',?this.prex);				}			}		});		//?局部組件		var?todoItem?=?{			props:?['content',?'prex'],			template:?'<li>{{prex}}?-?{{content}}</li>',		};		var?app?=?new?Vue({			el:?'#app',			data:?{				event:?'',				list:?[],			},			methods:{				submit:?function(){					if(!this.event.length)					{						alert('輸入值');					}					this.list.push(this.event);					this.event?=?'';				},				del:?function(event){					//?console.log(event.target.dataset.id);					let?prex?=?event.target.dataset.id;					this.list.splice(prex,?1);				},				handleDelete:?function(prex)?{					//?alert(prex);					this.list.splice(prex,?1);				},			}		});	</script></body></html>


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

舉報(bào)

0/150
提交
取消

不用組件拆分的方式,完成todolist功能

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

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

幫助反饋 APP下載

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

公眾號(hào)

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