Type'string [] []'不可分配给'string []'
让tagsUnparsed
是类似于"a b c d+e+f"
的字符串。我需要一个数组应该是:
["a", "b", "c", "d", "e", "f"]
在打字稿中,我尝试过此操作:
let tags: string[] = tagsUnparsed.split(' ');
tags = tags.map((tag: string) => {
return tag.split('+')
});
我收到此错误:
Type 'string[][]' is not assignable to type 'string[]'.
Type 'string[]' is not assignable to type 'string'.ts(2322)
我看不到string[][]
的来源。 .map
返回一个数组,不确定为什么会有类型定义错误。
Type'string [] []'不可分配给'string []'
让tagsUnparsed
是类似于"a b c d+e+f"
的字符串。我需要一个数组应该是:
["a", "b", "c", "d", "e", "f"]
在打字稿中,我尝试过此操作:
let tags: string[] = tagsUnparsed.split(' ');
tags = tags.map((tag: string) => {
return tag.split('+')
});
我收到此错误:
Type 'string[][]' is not assignable to type 'string[]'.
Type 'string[]' is not assignable to type 'string'.ts(2322)
我看不到string[][]
的来源。 .map
返回一个数组,不确定为什么会有类型定义错误。