代码先锋网 代码片段及技术文章聚合

修复Critical dependency: the request of a dependency is an expression警告

技术标签: js  学习  require加载问题  require警告  require只能传字符串  修复require加载

在这里插入图片描述

Critical dependency: the request of a dependency is an expression

关键依赖: 依赖关系的请求是一个表达式。

查看问题代码

let img = '@/assets/images/head.png';
require(img);

**原因在于**: require用于引入模块、 JSON、或本地文件,但是不支持直接传入变量。 **解决方法**:通过 [**ES6 字符串模板**](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/template_strings) 将变量转换为字符串即可。

参考 解决方法

let img = '@/assets/images/head.png';
require(`${img}`)

再无报错
在这里插入图片描述

版权声明:本文为wzp20092009原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wzp20092009/article/details/109817744

智能推荐

IDEA 警告 the package is not inside non-bundled dependency

iml文件的配置问题,删了如下配置即可:  ...

dependency

需要使用哪些标签就要添加哪些jar包(动态web工程需要下载jar包,maven工程添加依赖(依赖都在MVN)) 例如: 1、junit 该依赖是针对于单元测试 junit junit 4.11 test 2、针对于servlet的依赖 javax.servlet javax.servlet-api 4.0.1 provided 3、针对标签库的依赖(JSTL java stantard tag ...

dependency

ib 指令 : 引入对应的标签库,用于使用一些标签 需要使用哪些标签就要添加哪些jar包(动态web工程需要下载jar包,maven工程添加依赖(依赖都在MVN)) 例如: 1、junit 该依赖是针对于单元测试 junit junit 4.11 test 2、针对于servlet的依赖 javax.servlet javax.servlet-api 4.0.1 provided 3、针对标签库的...

RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating envi

今天用conda install 任何包都会出现这个错误: 参考网页: https://stackoverflow.com/questions/54392995/removeerror-requests-is-a-dependency-of-conda-and-cannot-be-removed-from-cond 方案一: 方案二: 方案三:...

RemoveError: 'requests' is a dependency of conda and cannot be removed

这个问题很简单,就是conda 的版本太旧了。有些pip安装的包有点小问题 解决方式也很简单,升级conda就行 然后再进行相关操作就行 ps,pip还经常提醒你要升级pip,这个conda从来都不提醒,还得遇到问题了百度才知道。ORZ...

猜你喜欢

RemoveError: 'requests' is a dependency of conda and cannot be removed from conda's operating enviro

这个问题很简单,就是conda 的版本太旧了。有些pip安装的包有点小问题 解决方式也很简单,升级conda就行 然后再进行相关操作就行 ps,pip还经常提醒你要升级pip,这个conda从来都不提醒,还得遇到问题了百度才知道...

【解决问题】RemoveError: 'requests' is a dependency of conda and cannot be removed from....

在安装tensorflow的时候报错:RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating environment. 在查资料的过程中,大概有三种的解决方法: 说是conda版本太低 升级conda即可,即:conda updat...

RemoveError requests is a dependency of conda 问题解决

在执行conda命令时报错RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating environment. 按照网上的各种办法,包括执行 还是继续报错,经过多番尝试,在执行 之后,问题解决。      ...

解决RemoveError: "setuptools" is a dependency of conda and cannot be removed from conda

昨天将显卡驱动从389更新为418之后,无法创建新环境,且无法删除旧环境,使用conda remove或者conda create命令均会报错: RemoveError: ‘setuptools’ is a dependency of conda and cannot be removed from conda 查了一堆博客,都是建议更新conda。 输入命令conda u...

Android 使用Lottie的三个小技巧

Android 使用Lottie的三个小技巧 Shawn 文章目录 Android 使用Lottie的三个小技巧 I 开启硬件加速 II 通过添加AnimatorListener来控制动画行为 III 通过设置播放速度来实现动画倒放 I 开启硬件加速 开启硬件加速是个提升lottie动画表现效果的一个好办法,在我的老手机上,不开硬件加速就跟幻灯片一样. II 通过添加AnimatorListene...