1 Star 0 Fork 0

yzishan / webs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
yangzishan 提交于 2023-11-22 17:13 . all
<!DOCTYPE html>
<html>
<head>
<title>testzishan</title>
<style type="text/css"></style>
<meta charset="UTF-8">
<script src="./vue.js"></script>
<body>
<div id="app">
<input type="text" v-model="inputValue">
<button v-on:click="handleBtnClick">提交</button>
<ul>
<!-- <li v-for="item in list">{{item}}</li> -->
<todo-item
:content="item"
:index="index"
v-for="(item,index) in list"
@delete="handelItemDelete"
></todo-item>
</ul>
</div>
<script>
// Vue.component("TodoItem",{
// template:"<li>{{content}}</li>",
// props:['content']
// });
var TodoItem = {
template:"<li @click='handleClick'>{{content}}</li>",
methods:{
handleClick: function(){
this.$emit("delete",this.index)
}
},
props:['content','index']
}
let app = new Vue({
el:'#app',
components:{
TodoItem,
},
data:{
list:[],
inputValue:''
},
methods:{
handleBtnClick: function(){
this.list.push(this.inputValue);
this.inputValue = ''
},
handelItemDelete:function(index){
this.list.splice(index,1)
}
}
});
</script>
</body>
</head>
</html>
1
https://gitee.com/yzishan/webs.git
git@gitee.com:yzishan/webs.git
yzishan
webs
webs
master

搜索帮助