6进口使用('@ ')在一个项目中使用vue.js WebPACK路径标志

Alexander O'MaraChris Schmitz提出了一个问题:ES6 import using at ('@') sign in path in a vue.js project using Webpack,或许与您遇到的问题类似。

回答者estus给出了该问题的处理方式:

This is done with Webpack resolve.alias configuration option and isn't specific to Vue.

In Vue Webpack template, Webpack is configured to replace @/ with src path:

  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      ...
      '@': resolve('src'),
    }
  },
  ...

希望本文对你有帮助,欢迎支持JavaScript中文网