亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

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

不用組件拆分的方式,怎樣實現todolist功能?有哪位小伙伴試過嗎?分享一下代碼?

正在回答

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 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

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

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號