【发布时间】:2026-02-07 01:20:12
【问题描述】:
我使用本教程: https://alligator.io/vuejs/rest-api-axios/ 并尝试像这样使用 axios: 在我的 main.js 文件中:
import axios from 'axios'
export const HTTP = axios.create({
baseURL: `http://api.com/api/`,
headers: {
// Authorization: 'Bearer {token}'
}
})
在我的 .vue 文件中:
import {HTTP} from './http-common';
let params = {
email: this.login,
pwd: this.pwd
}
HTTP.post(`login`, params)
.then(response => {
alert(response);
})
.catch(e => {
this.errors.push(e)
})
错误 ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/SignIn.vue 未找到模块:错误:无法解析“./http-common” 'C:\Users\direwolf\Documents\web\js\vue\quasar-crm\src\components' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/SignIn.vue 5:0-37 @ ./src/components/SignIn.vue @ ./src/router.js @ ./src/main.js@multi ./build/hot-reload.js ./src/main.js
【问题讨论】:
标签: vue.js