在bug区提过原帖地址,官方给的大幅定义这样是不行。故用了一个迂回的解决方式如下供大家参考
先定义一个Base基类
class Base { constructor() {// 把类中的的function取出来,赋值到实例中 const moduleFns = Object.getOwnPropertyNames(this.__proto__); moduleFns.map(propertyName => { if (propertyName !== 'constructor') { this[propertyName] = this[propertyName]; } }); }}module.exports = Base; |
业务代码如下
<view bindtap="bindTapTab"> |
js
const Base = require("base");class Home extends Base { constructor() { super() } customFn() {} bindTapTab() {} onLoad() { super.onLoad(); this.customFn(); }}Page(new Home()); |
