当我尝试导入此目录服务/ AuthenticationService中的另一个javascript文件时,我在vue组件中收到错误
找不到模块:错误:无法解析'@ / services / AuthenticationService' 要安装它,您可以运行:npm install --save @ / services / AuthenticationService
我已经搜索了这个问题的解决方案,但我找不到任何东西。任何帮助将不胜感激
这是我的视图组件register.vue
<template>
<div>
<h1>Register</h1>
<input type="email" name="email" v-model ="email" placeholder="email"> <br>
<input type="password" name="password" v-model ="password" placeholder="password"> <br>
<button @click="register">
Register
</button>
</div>
</template>
<script>
import AuthenticationService from '@/services/AuthenticationService'
export default {
data () {
return {
email: '',
password: ''
}
},
methods: {
async register(){
const response = await AuthenticationService.register({
email: this.email,
password: this.password
})
console.log(response.data)
}
}
}
</script>
<style scoped></style>
答案 0 :(得分:0)
你的webpack配置有解决方法吗?
resolve: {
alias: {
'@': path.resolve('path/to/your/source/folder')
}
}