- flattenOptions(options) {
- let flattenedOptions = []
- options.forEach((option) => {
- flattenedOptions.push(option)
- if (option.children && option.children.length > 0) {
- flattenedOptions = flattenedOptions.concat(this.flattenOptions(option.children))
- }
- })
- return flattenedOptions
- },
调用flattenOptions方法 传入要转换的数组 确定数组children有固定的标识