在需要dispatch的函数里,添加return Promise.resolve(返回值)

// 用户名登录
LoginByUsername({ commit }, userInfo) {
  const username = userInfo.username.trim()
  var md5 = crypto.createHash("md5")
  md5.update(userInfo.password)
  var password_MD5 = md5.digest('hex')
  return new Promise((resolve, reject) => {
    loginByUsername(username, password_MD5).then(response => {
      const data = response.data
      commit('SET_TOKEN', data.token)
      setToken(response.data.token)
      resolve(response)
    }).catch(error => {
      reject(error)
    })
  })
},

 

Logo

前往低代码交流专区

更多推荐