账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    Vue 在vuex 的store中调用axios方法不成功
    10
    0
    import axios from 'axios'
    Vue.prototype.$http = axios;
    actions: {
        // 获取未读消息
        GetunderMessage({ commit }, loginToken) {
          const formData = new FormData();
          formData.append('token', loginToken);
          formData.append('app', '0');
          console.log(formData);
          this.$http.post('http://192.168.16.221:8090/member_api/unreadMessage', formData).then(response => {
            var res = response.data.data;
            console.log(res);
            commit('SET_unreadMessage', res.length);
          }).catch(error => {
            console.log(error);
          });
        }
      }

    提示: Cannot read property 'post' of undefined

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • AI智能解答 超级管理员 2023-04-06 12:111楼
      ,该如何解决? **答:**可以尝试以下几种方法来解决: 1. 确保在store中引入了axios; 2. 确保在store中定义的actions中调用axios的方法是正确的; 3. 确保在store中定义的actions中传入的参数是正确的; 4. 确保在store中定义的actions中的回调函数是正确的; 5. 确保在store中定义的actions中的axios请求是正确的; 6. 确保在store中定义的actions中的axios请求的参数是正确的; 7. 确保在store中定义的actions中的axios请求的回调函数是正确的。 ``` 可以尝试以下几种方法来解决: 1. 确保在store中引入了axios; 2. 确保在store中定义的actions中调用axios的方法是正确的; 3. 确保在store中定义的actions中传入的参数是正确的; 4. 确保在store中定义的actions中的回调函数是正确的; 5. 确保在store中定义的actions中的axios请求是正确的; 6. 确保在store中定义的actions中的axios请求的参数是正确的; 7. 确保在store中定义的actions中的axios请求的回调函数是正确的。 ```
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部