当前位置:首页 > Web开发 > 正文

data:{ user:{ id: ""

2024-03-31 Web开发

标签:

new Vue({
el:"#app" ,
data:{
user:{
id:"",
username:"",
password:"",
age:"",
sex:"",
},
userList:[]
},
methods:{
findAll:function () {
//在当前要领中界说一个变量,,表白是vue东西
var _this= this;
axios.get(‘/day01_eesy_vuejsdemo/user/findAll.do‘)
.then(function (response) {
// handle success
_this.userList=response.data;
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
},
findById:function (userid) {
//在当前要领中界说一个变量,表白是vue东西
var _this= this;
axios.get(‘/day01_eesy_vuejsdemo/user/findById.do‘,{params:{id:userid}})
.then(function (response) {
// handle success
_this.user=response.data;
$("#myModal").modal("show");
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
},
update:function (user) { //post请求
//在当前要领中界说一个变量,表白是vue东西
var _this= this;
axios.post(‘/day01_eesy_vuejsdemo/user/updateUser.do‘, _this.user)
.then(function (response) {
_this.findAll();
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
},
created:function(){
this.findAll();
}
});
 

Vue中如何书写js来衬着页面填充数据的部分代码

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31191.html