- Behavior不能调用上层的methods
// behavior2.js module.exports = Behavior({ behaviors: [], methods: { aaa: { return [aa, bb] } } }) // behavior1.js module.exports = Behavior({ behaviors: [require('behavior2.js')], methods: { aaa: { //此处我想调用 behavior2.aaa(); 不知道如何调用。 //不能使用this.aaa(),会死循环 //const allPages = getCurrentPages(); //const props = allPages[allPages.length - 1]; 不能使用 props.aaa(); 一样会死循环。 //this.selectOwnerComponent() 为null //definitionFilter是上层处理下层的 const newAAA = behavior2.aaa(); newAAA.push(cc); return newAAA; } } }) // component.js Component({ behaviors: [require('behavior1.js')], })
2022-11-29 - Behavior多层调用时方法如何调用?
// behavior2.js module.exports = Behavior({ behaviors: [], methods: { aaa: { return [aa, bb] } } }) // behavior1.js module.exports = Behavior({ behaviors: [require('behavior2.js')], methods: { aaa: { //此处我想调用 behavior2.aaa(); 不知道如何调用。 //不能使用this.aaa(),会死循环 //const allPages = getCurrentPages(); //const props = allPages[allPages.length - 1]; 不能使用 props.aaa(); 一样会死循环。 //this.selectOwnerComponent() 为null //definitionFilter是上层处理下层的 const newAAA = behavior2.aaa(); newAAA.push(cc); return newAAA; } } }) // component.js Component({ behaviors: [require('behavior1.js')], })
2022-11-28