my.offNetworkStatusChange

Use this JSAPI to stop listening to the event of network status change. This is usually paired with the my.onNetworkStatusChange JSAPI.

Sample Code

copy
Page({
    listener(res) {
        console.log(res)
    },
    onNetworkStatusChange(){
        my.onNetworkStatusChange(this.listener)
    },
    offNetworkStatusChange() {
        //stop listening to the event of network status change.
        my.offNetworkStatusChange(this.listener)
    },
});

Parameters

Property

Type

Required

Description

listener

Function

Yes

The listener function that is passed by the onNetworkStatusChange method.

If this parameter is not passed, all listener events are removed.