ajax 或者 axios 或调函数中 指向vue 实例
2017-02-20 11:04
876 查看
1.箭头函数 (resp) => {//函数体}
或者
function (res) {}.bind(this)
或者
function (res) {}.bind(this)
axios.post('/app/user/loginSubmit',data) .then(function(res){ if(res.data){ this.error = ''; window.location.href = '/'; }else { this.error = '帐号或者密码错误'; } //console.log(res); }.bind(this)) .catch(function(err){ //console.log(err); }); axios.post('/app/user/loginSubmit',data) .then((res)=>{ if(res.data){ this.error = ''; window.location.href = '/'; }else { this.error = '帐号或者密码错误'; } })
相关文章推荐
- vue使用axios中 this 指向问题
- 在其他class或者view中获取MainActivity实例,以便调用其函数的方法:
- vue项目使用axios发送请求让ajax请求头部携带cookie的方法
- 输入两个整数,然后让用户选择1或者2,选1是调用max函数,输出二者中大数,选2时调用min函数输出二者中的小数(指向函数的指针变量)
- VUE 更好的 ajax 上传处理 axios.js实现代码
- Vue官方推荐AJAX组件axios.js使用方法详解与API
- vue使用axios中 this 指向问题
- springboot vue.js axios.js ajax请求纯HTML页面传值
- vue项目使用axios发送请求让ajax请求头部携带cookie
- vue页面离开后执行函数的实例
- 指针—指向函数的指针实例 fun函数
- C++语言实现指向函数的指针数组实例
- vue中的ajax - axios
- C++指向函数的指针实例解析
- vue发送ajax --axios入门介绍
- vue利用axios来完成数据的交互实例及安装方法
- vue使用axios时关于this的指向问题详解
- vue-router钩子beforeRouteEnter函数获取到this实例
- vuex + axios 做登录验证 并且保存登录状态的实例
- js 函数作用域与this 的指向实例