vue导入文件

在vue中的css部分,看到以下导入文件的方法:

<style scoped lang="stylus" rel="stylesheet/stylus">
    @import "~common/stylus/variable"
    @import "~common/stylus/mixin"
    
</style>

在webpack中指定了文件路径前缀,为什么还有~?

阅读 5.6k
2 个回答

import 和 require 才有用

clipboard.png

这个 ~ 是你自己指定的符号,你可以看你的webpack的resolve 的 alias部分,
就比如:

alias: {
      '~src': resolve('src'),
      '~components': resolve('src/components'),
      '~pages': resolve('src/pages'),
      '~assets': resolve('src/assets'),
      '~store': resolve('src/store')
    }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题