默认情况下,默认情况下,在Webpack中定义了一个别名(alias):@

@/components 等价于 src/components

对应的文件夹是 src 文件夹,是通过path.resolve()实现的:

configureWebpack: {

resolve: {

alias: { '@': resolve('src') }

}

}

另外,倘若我们为components设置了别名:

configureWebpack: {

resolve: {

alias: { 'components': resolve('src/components') }

}

}

此时我们在项目中其他位置需要使用到components的路径时,就可以忽略前面的部分,直接使用:

import HelloWorld from "./src/components/HelloWorld.vue"

import HelloWorld from "components/HelloWorld.vue"

参考阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: