ESLint:Require语句不属于import语句。(@ typescript-eslint / no-var-requires) [英] ESLint: Require statement not part of import statement.(@typescript-eslint/no-var-requires)
本文介绍了ESLint:Require语句不属于import语句。(@ typescript-eslint / no-var-requires)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从本机 BackgroundImage 添加背景图像,该图像需要将源添加为 source = {require('*-iamge path-*' )}
I'm trying to add a background image from react native BackgroundImage which needs to add source as source={require('*--iamge path --*')}
,但是我随便扔了 Require语句不属于import语句。错误。我尝试以不同的方式导入图像,例如:
but my eslint throw Require statement not part of import statement. error. i have tried to import image in different ways for example:
- const image = '--image path--'
- import image = require('--image path--')
- <BackgroundImage source={require('--image path--')}>
推荐答案
您可以在 eslintrc.js
文件
module.exports = {
...
rules: {
...
'@typescript-eslint/no-var-requires': 0,
}
}
这篇关于ESLint:Require语句不属于import语句。(@ typescript-eslint / no-var-requires)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文