0

我有一个对象,其中包含以点“journey.hintText.journeyTags”为键的字符串。(由我无法修改的 api 响应返回)。我想破坏像 const {journey.hintText.journeyTags} = content 这样的内容对象,但它会引发错误。请让我知道如何破坏内容对象,非常感谢。

const content = {journey.hintText.journeyTags: 'Please select a tag'}
4

1 回答 1

2

您可以使用计算属性,但您应该提供这样的名称const { ['journey.hintText.journeyTags']: journeyTags } = content

于 2021-03-23T00:02:10.330 回答