本文共 1108 字,大约阅读时间需要 3 分钟。
[HTML] 纯文本查看 复制代码
编号ser_ipftp_ab_pathftp_ac_pathrestart操作
{ {index+1}}{ {item.ser_ip}}{ {item.ftp_ab_path}}{ {item.ftp_ac_path}}{ {item.restart}}移除修改添加完成var vm =new Vue({
el:'#table',
data:{
item:{ser_ip:'',ftp_ab_path:'',ftp_ac_path:'',restart:''},
list: [],
bEditing: false,
},
methods:{
getJson:function(){
$.ajax({
type: "GET",
url: "db.json",
dataType: "json",
success: function (data) {
console.info(data);
if(data){
vm.list = JSON.parse(data);
}
}
});
},
saveJson:function(){
$.ajax({
type: "POST",
url: "putjson.php",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(this.list),
dataType: "json",
success: function (message) {
if (message > 0) {
alert("提交数据Success!");
}
},
error: function (message) {
alert("提交数据失败!");
}
});
},
insert:function(){
var aItem = Object.assign({}, this.item);
this.list.push(aItem)
this.saveJson();
},
remove:function(index){
this.list.splice(index,1)
this.saveJson();
},
edit:function(index){
this.item = this.list[index];
//this.set()
this.bEditing = true;
},
eidtOver:function(index){
this.bEditing = false;
this.saveJson();
}
}
});
vm.getJson();
转载地址:http://qbnzx.baihongyu.com/