<head>
<meta charset="utf-8">
<title></title>
<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
* {
margin: 0 auto;
padding: 0;
}
.book {}
</style>
</head>
<body>
<div id="app">
<div class="da">
<div class="book">
<div>
<label for="id">
编号:
<input type="text" id="id" v-model='id' />
</label>
<label for="name">
名称:
</label>
<input type="text" id="name" v-model='name' />
<button @click="handle">提交</button>
</div>
</div>
</div>
<thead>
<table border="1" width="500" height="200">
<th>编号</th>
<th>名称</th>
<th>时间</th>
<th>操作</th>
</tr>
</thead>
<tr :key='item.id' v-for='item in bosl'>
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td>{{item.date}}</td>
<td>
<a href="" @click.prevent>修改</a> <!-- prevent阻止默认跳转 -->
<span>|</span>
<a href="" @click.prevent>删除</a>
</td>
</tr>
</table>
</div>
</div>
</body>
<script type="text/javascript">
var mv = new Vue({
el: '#app',
data: {
bosl: [{
id: 1,
name: '王者',
date: ''
},
{
id: 2,
name: '穿越',
date: ''
},
{
id: 3,
name: '飞车',
date: ''
},
{
id: 4,
name: 'HTML',
date: ''
},
]
},
methods: {
handle: function() {
var book = {};
book.id = this.id;
book.name = this.name;
book.date = "";
this.bosl = plus(book);
//清空表单
this.id = '';
this.name = '';
}
}
});
</script>
id和name为什么报没有定义
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- 南柯ღk 2021-08-31 09:01关注
我稍微改了点就行了,能渲染出来了
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> <div class="da"> <div class="book"> <div> <label for="id"> 编号: <input type="text" id="id" v-model='id'/> </label> <label for="name"> 名称: </label> <input type="text" id="name" v-model='name'/> <button @click="handle">提交</button> </div> </div> </div> <thead> <table border="1" width="500" height="200"> <th>编号</th> <th>名称</th> <th>时间</th> <th>操作</th> </tr> </thead> <tr :key='item.id' v-for='item in bosl'> <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.date}}</td> <td> <a href="" @click.prevent>修改</a> <!-- prevent阻止默认跳转 --> <span>|</span> <a href="" @click.prevent>删除</a> </td> </tr> </table> </div> <script src="../js/vue.js"></script> <script> new Vue({ el: '#app', data: { bosl: [{ id: 1, name: '王者', date: '' }, { id: 2, name: '穿越', date: '' }, { id: 3, name: '飞车', date: '' }, { id: 4, name: 'HTML', date: '' }, ] }, methods: { handle: function() { var book = {}; book.id = this.id; book.name = this.name; book.date = ""; this.bosl = plus(book); //清空表单 this.id = ''; this.name = ''; } } }); </script> </body> </html>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 Llama如何调用shell或者Python
- ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
- ¥15 win10权限管理,限制普通用户使用删除功能
- ¥15 minnio内存占用过大,内存没被回收(Windows环境)
- ¥65 抖音咸鱼付款链接转码支付宝
- ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
- ¥15 blast算法(相关搜索:数据库)
- ¥15 请问有人会紧聚焦相关的matlab知识嘛?
- ¥15 网络通信安全解决方案
- ¥50 yalmip+Gurobi