setDisabled(val) {
val.forEach((item) => {
item.disabled = true
if (item.menu) {
this.setDisabled(item.menu)
}
})
return val
},
var o = [
{},
{},
[
{ val: ' 110 ' },
[
{
val: 'a2312312a',
},
],
{
val: '12315',
fn: function () {
return 'ok'
},
},
],
{},
[
[
{
val: '120',
fn: function () {
throw new Error('此方法不可运行')
},
},
],
],
]
let bb = []
function aa(val) {
val.forEach((item) => {
if (item.val && /^\d+$/.test(item.val)) {
bb.push(item.val)
try {
item.fn()
bb.push(item.fn())
} catch (e) {
bb.push(-1)
}
}
if (Array.isArray(item)) {
aa(item)
}
})
}
undefined
aa(o)
undefined
bb
["12315", "ok", "120", -1]