页面通信

(不能跨小程序通信)

fund.on(Object)

监听事件

参数

Object说明

属性 类型 必填 说明
eventName string 要监听的事件名称
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

fund.on({
    eventName: "click",
    success: function(res) {
    modal.toast({
        message: res,
        duration: 0.3
            });
    }
});
1
2
3
4
5
6
7
8
9

fund.off(Object)

取消事件的监听

参数

Object说明

属性 类型 必填 说明
eventName string 取消监听的事件名称
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

fund.on({
    eventName: "click",
    success: function(res) {
    modal.toast({
        message: res,
        duration: 0.3
            });
    }
});
1
2
3
4
5
6
7
8
9

fund.emit(Object)

发送事件

参数

Object说明

属性 类型 必填 说明
eventName string 发送事件的名称
data Object 发送事件携带的数据
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

fund.emit({
    eventName: "click",
    data: {
        a: "123"
    },
    success: res => {
        modal.toast({
            message: "发布成功",
            duration: 0.3
        });
    }
});
1
2
3
4
5
6
7
8
9
10
11
12

fund.offAll(Object)

取消所有事件的监听

参数

Object说明

属性 类型 必填 说明
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

fund.offAll({
    success: res => {
        modal.toast({
            message: "清除成功",
            duration: 0.3
        });
    }
});
1
2
3
4
5
6
7
8
Last Updated: 12/18/2019, 6:47:50 PM