Bootstrap + Vue.js implements adding and deleting data

高洛峰
Release: 2017-02-28 14:30:36
Original
1654 people have browsed it

The interface first needs to introduce bootstrap css and bootstrap js files, as well as vue.js and jQuery.js to see the effect.

The online files of bootstrap are provided here for your reference:

 
Copy after login

 
Copy after login

The effect is as shown in the figure below. Enter the user name and age, click Add, and the data will be automatically added to the user information table below. When there is no data, the user information table displays: No data yet... When there is data, a delete all button is displayed. For convenience and speed, I did not create a pop-up box for the delete button, so clicking the delete button will directly delete the current item. Article data.

Bootstrap + Vue.js实现添加删除数据

Bootstrap + Vue.js实现添加删除数据

##


用户信息表
序号 名字 年龄 操作
{{index+1}} {{item.name}} {{item.age}}

暂无数据……

Copy after login

window.onload = function(){ new Vue({ el:"#box", data:{ myData:[], username:'', age:'', nowIndex:-100 }, methods:{ add:function(){ this.myData.push({ name:this.username, age:this.age }); this.username=''; this.age=''; }, deleteMsg:function(){ this.myData.splice(0,1) }, all:function(){ this.myData = []; } } }) }
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's learning. I also hope that everyone will support the PHP Chinese website.

For more articles related to Bootstrap + Vue.js for adding and deleting data, please pay attention to the PHP Chinese website!



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn