JavaScript 使用变量作为对象的key LiuYoga 2022-06-04 369 阅读1分钟 把变量 key 作为obj的键: const key = 'keyName'; const obj = { [key]: 'keyvalue' } console.log(obj) 得到效果: