其他分享
首页 > 其他分享> > 2022-04-01This dependency was not found:

2022-04-01This dependency was not found:

作者:互联网

2022-04-01
详细报错代码:

This dependency was not found:

* @/components/subsidy in ./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--12-0!./node_modules/_babel-loader@8.2.4@babel-loader/lib!./node_modules/_cache-loader@4.1.0@cache-loader/dist/cjs.js??ref--0-0!./node_modules/_vue-loader@15.9.8@vue-loader/lib??vue-loader-options!./src/views/subsidy_audit/subsidy_audit.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save @/components/subsidy

前言:vue项目,写了个组件,引入到父级,报错。
报错意思也很简单,就是说识别不了我这个组件subsidy。
排错过程:
引入方式:import Subsidy from '@/components/subsidy';
在components加入了组件名:
components: {
Subsidy,
},
思来想去,发现是我定义的组件写法问题,它应该是识别不了在subsidy文件夹里的subsidy.vue文件,
如果路径是@/components/subsidy这样的,那么它应该需要一个index.js来当作入口文件,然后我把我的组件导入index.js,然后接着导出就行了。
index.js代码:
import Subsidy from './subsidy.vue'
export default Subsidy
嗯,问题解决!

标签:Subsidy,vue,components,04,loader,subsidy,dependency,2022,js
来源: https://www.cnblogs.com/iuniko/p/16148447.html