这次给大家带来vue实现搜索列表内容,vue实现搜索列表内容的注意事项有哪些,下面就是实战案例,一起来看一下。
效果图如下所示:
无标题页 .box { width: 900px; height: auto; overflow: hidden; margin: 30px auto; } .left { height: 150px; width: 185px; padding: 5px; display: inline-block; border: 1px solid black; } .left input { padding: 2px; margin-top: 10px; } .right { width: 600px; height: auto; display: inline-block; margin-left: 30px; vertical-align: top; } .right table { border-collapse: collapse; width: 580px; } .right table th { background-color: green; padding: 5px; text-align: center; border: 1px solid black; color: #FFFFFF; } .right table tr { text-align: center; } .right table td { border: 1px solid black; }
编号 | 品牌名称 | 创建时间 | 操作 |
---|---|---|---|
{{item.id}} | {{item.name}} | {{item.time | datefmt('yyyy-mm-dd HH:mm:ss')}} | 删除 |
{{HospPatientName}} {{HospCardType}}
{{HospCardNo}}
{{HospIsDefault}}
*/ } }; var vm = new Vue({ el: '#app', data: { id: '', name: '', search: '', list: [{ "id": 1, "name": "宝马", "time": new Date() }, { "id": 2, "name": "奔驰", "time": new Date() } ] }, methods: { del: function (id) { if (!confirm("是否删除数据?")) { return; } //调用list.findIndex()方法,根据传入的id获取到这个要删除数据的索引值 var index = this.list.findIndex(function (item) { return item.id == id; }); //调用list.splice(删除的索引,删除的元素个数) this.list.splice(index, 1); }, add: function () { //包装成list要求的对象 var tem = { id: this.id, name: this.name, time: new Date() }; //将tem追加到list数组中 this.list.push(tem); //清空页面上的文本框中的数据 this.id = ""; this.name = ""; } }, computed: { searchData: function () { var search = this.search; if (search) { return this.list.filter(function (name) { return Object.keys(name).some(function (key) { return String(name[key]).toLowerCase().indexOf(search) > -1 }) }) } return this.list; } } })登录后复制
相信看了本文案例你已经掌握了方法,更多精彩请关注【创想鸟】其它相关文章!
推荐阅读:
vue-router使用总结(附代码)
axios+post方法提交formdata步骤详解
以上就是vue实现搜索列表内容的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2762717.html