vue项目中的~到底代表什么,为何我使用的时候会报错
<style lang="stylus" scoped rel="stylesheet/stylus">
@import "~common/stylus/variable"
#app
color:$color-theme
</style>
我在一些代码中看到有人这样使用,我猜测这可能是一种自动化的路径代替
但是我自己使用却报错了
必须换成
@import "./common/stylus/variable"
才能生效,我想知道这东西应该如何去使用
下面是报错提示
Module build failed: Error: C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\src\App.vue:15:9
11| </script>
12|
13| <style lang="stylus" scoped rel="stylesheet/stylus">
14|
15| @import "~common/stylus/variable"
---------------^
16|
17| #app
18| color:$color-theme
failed to locate @import file ~common/stylus/variable.styl
at CachedPathEvaluator.visitImport (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus-loader@3.0.1@stylus-loader\lib\evalua
tor.js:157:21)
at CachedPathEvaluator.Visitor.visit (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\index.js:
28:40)
at CachedPathEvaluator.Evaluator.visit (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\evaluat
or.js:160:18)
at CachedPathEvaluator.Evaluator.visitRoot (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\eva
luator.js:707:27)
at CachedPathEvaluator.Visitor.visit (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\index.js:
28:40)
at CachedPathEvaluator.Evaluator.visit (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\evaluat
or.js:160:18)
at CachedPathEvaluator.Evaluator.evaluate (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\visitor\eval
uator.js:247:15)
at Renderer.render (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus@0.54.5@stylus\lib\renderer.js:86:26)
at C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_stylus-loader@3.0.1@stylus-loader\index.js:165:12
at tryCatchReject (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\makePromise.js:840:30)
at runContinuation1 (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\makePromise.js:799:4)
at Fulfilled.when (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\makePromise.js:590:4)
at Pending.run (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\makePromise.js:481:13)
at Scheduler._drain (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\Scheduler.js:62:19)
at Scheduler.drain (C:\Users\Laoliu\VsCodeProject\vue-mobile-music-app\node_modules\_when@3.6.4@when\lib\Scheduler.js:27:9)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
@ ./~/_vue-style-loader@3.0.2@vue-style-loader!./~/_css-loader@0.28.7@css-loader?{"minimize":false,"sourceMap":false}!./~/_vue-loader@13.0.4@vue-loa
der/lib/style-compiler?{"vue":true,"id":"data-v-19b3b84a","scoped":true,"hasInlineConfig":false}!./~/_stylus-loader@3.0.1@stylus-loader?{"sourceMap":
false}!./~/_vue-loader@13.0.4@vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-454 13:3-17:5 14:22-462
@ ./src/App.vue
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
https://athena0304.gitbooks.i...
~ 是哪个模块的功能?我想用用不了,alias里配置了了
我的配置
postcss.config.js
需要去webpack里面配置,有些人用@ 表示从src目录开始
如果你用脚手架的话,在目录结构里有个
build 的文件夹下面的wepack.base.conf.js
里面有以下代码
~应该是默认代表当前项目的更目录,需要在alias里面配置个别名,我直接上代码吧
webpack.base.config.js文件里,我的scss文件都在common目录下面,所以在alias里配置了common别名:
引用scss的代码:
亲测可以,有问题留言。