且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在import语句中使用模板文字?

更新时间:2022-12-28 23:09:10

为什么会发生错误?

Why does the error occur?

看来您自己找到了答案:

It seems you found the answer yourself:

import 语句似乎需要常规字符串

The import statement seems to require a regular string

完全正确. import 需要一个字符串 literal .导入位置不能是动态的.

Exactly. import needs a string literal. It import location cannot be dynamic.

相关: node.js中的ES6变量导入名称?