0
我想在常量文件中声明一个键值对象,然后导入它们。所以,这是我写的:在express.js中定义常量
let ACCEPTABLE_LANGUAGES =
[
'eng' : {'wahid'},
];
export default {
ACCEPTABLE_LANGUAGES : ACCEPTABLE_LANGUAGES
}
我将其导入:import common_constants from '../common_constants';
和使用如下:
console.log(common_constants.ACCEPTABLE_LANGUAGES);
但ACCEPTABLE_LANGUAGES
申报给我的错误,如:
Unexpected token, expected : (3:18)
1 | let ACCEPTABLE_LANGUAGES =
2 | [
> 3 | 'eng' : {'wahid'},
| ^
4 | ];
我想让它对象不是数组。为什么我得到这个问题?
您需要将数组符号('[]')与对象符号('{}')交换,反之亦然 – lumio