<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo1</title>
<script src="https://cdn.bootcss.com/vue/2.4.1/vue.js"></script>
</head>
<body>
<div id="app">
{{message}}
</div>
<script>
new Vue({
el:'#app',
data:{
message:'hello world'
}
})
</script>
</body>
</html>
var todoItem=function(title,desc){
this.title=title;
this.desc=desc;
}
<div id="app">
<form>
<input type="text" v-model="title"> <br>
<input type="text" v-model="desc"> <br/>
<input type="button" value="add todo item" v-on:click="addItem()" />
</form>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo1</title>
<script src="https://cdn.bootcss.com/vue/2.4.1/vue.js"></script>
</head>
<body>
<div id="app">
<form>
title:<input type="text" v-model="title"> <br>
desc:<input type="text" v-model="desc"> <br/>
<input type="button" value="add todo item" v-on:click="addItem()" />
</form>
</div>
<script>
var TodoItem = function (title, desc) {
this.title = title;
this.desc = desc;
}
new Vue({
el: '#app',
data: {
todolist:[],
title:'',
desc:''
},
methods:{
addItem:function(){
this.todolist.push(new TodoItem(this.title,this.desc))
this.title=this.desc='';
console.log(JSON.stringify(this.todolist));
}
}
})
</script>
</body>
</html>
<table style="width:300px;border-collapse:collapse" border="1">
<tr>
<th>title</th>
<th>desc</th>
</tr>
<tr v-for="todoItem in todolist">
<td>{{todoItem.title}}</td>
<td>{{todoItem.desc}}</td>
</tr>
</table>
<table style="width:300px;border-collapse:collapse" border="1">
<tr>
<th>title</th>
<th>desc</th>
<th></th>
</tr>
<tr v-for="(todoItem,index) in todolist">
<td>{{todoItem.title}}</td>
<td>{{todoItem.desc}}</td>
<td><input type="button" value="remove" @click="remove(index)" /></td>
</tr>
</table>
new Vue({
el: '#app',
data: {
todolist:[],
title:'',
desc:''
},
methods:{
addItem:function(){
this.todolist.push(new TodoItem(this.title,this.desc))
this.title=this.desc='';
},
remove:function(index){
this.todolist.splice(index,1);
}
}
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>demo1</title>
<script src="https://cdn.bootcss.com/vue/2.4.1/vue.js"></script>
<style>
table{
margin-top: 5px;
width:300px;
border-collapse: collapse;
border: 1px solid #ccc;
}
table > tr>th,table>tr>td{
height: 25px;
line-height: 25px;
}
</style>
</head>
<body>
<div id="app">
<form>
title:<input type="text" v-model="title"> <br>
desc:<input type="text" v-model="desc"> <br/>
<input type="button" value="add todo item" v-on:click="addItem()" />
</form>
<table style="width:300px;border-collapse:collapse" border="1">
<tr>
<th>title</th>
<th>desc</th>
<th></th>
</tr>
<tr v-for="(todoItem,index) in todolist">
<td>{{todoItem.title}}</td>
<td>{{todoItem.desc}}</td>
<td><input type="button" value="remove" @click="remove(index)" /></td>
</tr>
</table>
</div>
<script>
var TodoItem = function (title, desc) {
this.title = title;
this.desc = desc;
}
new Vue({
el: '#app',
data: {
todolist:[],
title:'',
desc:''
},
methods:{
addItem:function(){
this.todolist.push(new TodoItem(this.title,this.desc))
this.title=this.desc='';
},
remove:function(index){
this.todolist.splice(index,1);
}
}
})
</script>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有