修复Critical dependency: the request of a dependency is an expression警告
Critical dependency: the request of a dependency is an expression
关键依赖: 依赖关系的请求是一个表达式。
查看 问题代码:
let img = '@/assets/images/head.png';
require(img);
原因在于: require用于引入模块、 JSON、或本地文件,但是不支持直接传入变量。
解决方法:通过 ES6 字符串模板 将变量转换为字符串即可。
参考 解决方法
let img = '@/assets/images/head.png';
require(`${img}`)
再无报错
修复Critical dependency: the request of a dependency is an expression警告相关推荐
- Critical dependency: the request of a dependency is an expression
vue2项目 当你百分百确认你的代码没有任何问题时,但是powershell还是报了错误[Critical dependency: the request of a dependency is an ...
- 如何解决 Critical dependency: the request of a dependency is an expression ?
在使用若依后台时,在部分情况下会出现以下错误: 根据提示我们可以找到主要造成这个问题的代码是以下这段: export const loadView = (view) => { // 路由懒加载r ...
- Vue Cli webpack打包出现Waring :Critical dependency: the request of a dependency is an expression
错误信息: Waring 写法: let name = require(url); 如下写法,错误消失: let name = require(`${url}`);
- Python的Request请求跳过认证及禁用警告
1.跳过认证 在使用python做测试测试的时候,因为认证报错,可以添加verify=False跳过认证,如下: 2.禁用警告 此时,代码运行不受影响,请求会成功,但结果会报错: 不影响运行,但感觉不 ...
- 从安装认识Angular 2
关于介绍,只说一句:Angular 2是一个强大.全面.庞大的MVVM框架. 安装 安装,也算是一个坎,因为你需要安装一大堆东西,却不知道每个东西是做什么的,尽管有Angular-cli全家桶,但是个 ...
- nodejs+react使用webpack打包时控制台报错
一.错误:Uncaught ReferenceError: process is not defined 解决方法: new webpack.DefinePlugin({'process.env': ...
- 关于vue 动态引入(异步加载import和require)组件的方法和坑(按需懒加载组件,动态生成路由)babel-plugin-dynamic-import-node 优化编译速度
前言: 最近在改造vue-cli 2.x + webpack2.x的项目时,由于之前路由是静态的,没有根据菜单权限动态生成前端路由.所以想对此进行改造,然后碰到了一些问题和坑,现在总结一下,避免以后继 ...
- Cannot find module xxx,错误解决方法
文章目录 问题描述 浏览器错误信息 node控制台错误信息 解决方法 问题描述 最近项目从新拉取时install后就报路由编译错误的问题, 使用的是若依2.0项目 浏览器错误信息 node控制台错误信 ...
- [乐意黎原创] WebPack 打包时抛Uncaught Error: Cannot find module '.\dist\bundle.js'
如题:WebPack 打包时抛Uncaught Error: Cannot find module '.\dist\bundle.js' A. Webpack 命令时抛错 B.运行时Chrome 控制 ...
最新文章
- 多态基类与虚析构函数
- idea关联mysql失败_Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezon‘
- calibre中的hcell_关于calibre的Hcell你知道多少?
- 使用git pull文件时和本地文件冲突怎么办?
- 从去除毛刺的策略看开运算opening_circle和闭运算closing_circle的异同
- border-sizing属性详解和应用
- Zabbix通过Smokeping检测网络质量并告警
- centos7.3 防火墙设置
- 用turtle实现动态汉诺塔
- html打开网页一段时间字幕滚动,网页代码:求一个隔段时间可停顿的滚动字幕代码...
- Ruff自主研发的NB-IoT智能网关获得联通实验室测试通过
- 微信公众号开发:网页授权
- Coreldraw 制作透明小水滴按钮(转)
- jQuery中的siblings()的用法
- 让美容院业绩翻番,您只差一套软多共享股东系统
- linux动态压缩硬盘,VirtualBox 压缩VDI硬盘
- forkJoin源码解读
- 2015上半年手机GPU排行榜
- 人眼内的三类视锥细胞
- 通向架构师的道路(第二十六天)漫谈架构与设计文档的写作技巧