Vue中如何解决"This dependency was not found"的问题

发布时间:2021-07-20 09:45:45 作者:小新
来源:亿速云 阅读:285

这篇文章主要为大家展示了“Vue中如何解决"This dependency was not found"的问题”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Vue中如何解决"This dependency was not found"的问题”这篇文章吧。

在初始化项目中,出现了一个奇怪的情况:明明路径是对的,但是编译的时候,一直报“This dependency was not found”的错。

代码如下:

import Vue from 'vue'
import App from './App'
import router from './router'
import 'common/stylus/index.styl'
/* eslint-disable no-new */
new Vue({
 el: '#app',
 render: h => h(App)
})

控制台一直报错,表示无法找到common/stylus/index.styl,然而,路径是通过ide补全填写的,不可能出现错误,那又是为什么?

在网上多番搜索发现,Vue中的引入文件时,需要通过./通知编译器是在当前路径,不然的话,第一个文件夹名会被认为是webpack配置的alias(别名)。

所以,正确引入index.styl的方式是:

import Vue from 'vue'
import App from './App'
import router from './router'
import './common/stylus/index.styl' // 添加./避免编译器认为是别名
/* eslint-disable no-new */
new Vue({
 el: '#app',
 render: h => h(App)
})

以上是“Vue中如何解决"This dependency was not found"的问题”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. 使用pytest-dependency解决用例间的依赖问题
  2. 正确理解use-default-filters="false"

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vue

上一篇:如何解决vue elementUI中table里数字、字母、中文混合排序问题

下一篇:怎么修改gazebo物理参数

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》