首页 > 解决方案 > 如何导入名称中带有特殊字符的文件

问题描述

如何在 ES6 中导入名称中包含特殊字符的文件?

我可以

import { tomorrow} from 'react-syntax-highlighter/dist/esm/styles/hljs';

但我不能:

import { tomorrow-night} from 'react-syntax-highlighter/dist/esm/styles/hljs';

标签: javascriptreactjsimportes6-modulesreact-syntax-highlighter

解决方案


JavaScript 不支持变量名中的连字符。它们保留用于减法。


推荐阅读