Vue中如何书写js来渲染页面填充数据的部分代码
2024-10-13 07:39:39
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();
}
});
最新文章
- Live2d-cocos2dx教程(一)例子搭建及运行
- synchronized的实现原理-java并发编程的艺术读书笔记
- apache启动时80端口占用的解决方法
- escape()、encodeURI()、encodeURIComponent()区别详解
- uTenux——软件底层驱动组织结构介绍
- 集成 WeChat SDK - 支付篇
- EF入门 IQueryable和IEnumberable的区别
- FCLK PCLK HCLK
- SEAndroid安全机制对Binder IPC的保护分析
- java开发经验分享(二)
- crontab演出newLISP脚本设置环境变量
- Insertion Sort List Leetcode
- static 还是readonly 还是static readonly
- Extensions in UWP Community Toolkit - Overview
- 使用Spring Cloud搭建服务注册中心
- Leetcode: Encode and Decode TinyURL
- 华硕X75VB安装ubuntu12.10网卡不可用等相关问题总结
- opcode cache与JIT的区别
- Android开源框架Afinal第一篇——揭开圣女的面纱
- 【题解】Luogu P2783 有机化学之神偶尔会做作弊
热门文章
- pip 常用命令小结
- 执行对象Statement、PreparedStatement和CallableStatement详解
- 基于hadoop_yarn的资源隔离配置
- js 增删节点
- [hdu6997]愿望幽灵
- [cf1392I]Kevin and Grid
- Ubuntu 18.04 WMware 编译 AOSP android-7.1.2_r33 笔记
- BehaviorTree.CPP.行为树XML格式(六)
- Codeforces 1290D - Coffee Varieties(分块暴力+完全图的链覆盖)
- 【豆科基因组】绿豆Mungbean, Vigna radiata基因组2014NC