错误无法编译,出现1个错误未找到此依赖项:

时间:2018-05-15 14:57:04

标签: javascript vue.js webpack-dev-server

当我尝试导入此目录服务/ 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>

1 个答案:

答案 0 :(得分:0)

你的webpack配置有解决方法吗?

resolve: {
  alias: {
    '@': path.resolve('path/to/your/source/folder')
  }
}

文件https://webpack.js.org/configuration/resolve/