javascript - 错误 编译失败,出现 1 个错误 未找到此依赖项:
问题描述
当我尝试导入此目录 services/AuthenticationService 中的另一个 javascript 文件时,我在 vue 组件中遇到错误
Module not found: Error: Can't resolve '@/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>
解决方案
你的 webpack 配置中有解决方案吗?
resolve: {
alias: {
'@': path.resolve('path/to/your/source/folder')
}
}
推荐阅读
- javascript - 滑块背景
- android - 相机服务活页夹在缩放后死亡
- python - How to loop through pandas df column, finding if string contains any string from a separate pandas df column?
- scala - 使用基于'A','E','I','O','U'元音的scala在Spark(核心使用RDD)WordCount程序中创建5个分区文件
- python - Pygame problem: how to execute conditional on collision?
- c# - unity C# 中不能有多个基类
- python - 可以多次访问客户的 CVRP
- xml - 雪花 PARSE_XML 规范化属性?
- x86 - 访问另一个处理器的本地 APIC
- shell - Condition on Nth character of string in a Mth column in bash