Closed zifeiyu-12321 closed 3 years ago
应用场景:动态require模块时如下 this.handbook = require(@/assets/md/${newVal}.md); 会出现如下报错
@/assets/md/${newVal}.md
【(parameter) newVal: any Calls to require() should use string literalseslintimport/no-dynamic-require Unexpected require().eslintglobal-require】 请问如何解决
这种用法是 Airbnb 规范里禁止的。 https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
请改用 import 来动态引入模块。 或者加注释临时禁用这条规则 // eslint-disable-line import/no-dymanic-require
import
// eslint-disable-line import/no-dymanic-require
应用场景:动态require模块时如下 this.handbook = require(
@/assets/md/${newVal}.md
); 会出现如下报错【(parameter) newVal: any Calls to require() should use string literalseslintimport/no-dynamic-require Unexpected require().eslintglobal-require】 请问如何解决