Ionic cordova-插件-antplus不适用于离子3 [重复]

iyzzxitl  于 2022-12-16  发布在  Ionic
关注(0)|答案(1)|浏览(138)

此问题在此处已有答案

(9个答案)
四年前关闭了。
这是我的代码:

public antplus: any;
public SelectId: any;

constructor(public navCtrl: NavController) {
    this.antplus = (<any>window).antplus;
    this.antplus.searchDevices('HEARTRATE', function(device) {
        console.log(JSON.stringify(device));
        console.log("Ant ID=" + device.antDeviceNumber);
        this.SelectId = device.antDeviceNumber;
    },(error)=>{console.log("Error Search="+error);});
}

在控制台上会显示[INFO:CONSOLE(64)]“Ant ID=4077”。
但也会收到错误消息:成功回调ID:安替普卢斯1239198979:TypeError:无法将属性“SelectId”设置为null。
以前有人遇到过这种问题吗?

iq0todco

iq0todco1#

public antplus: any;
    public SelectId: any;

    constructor(public navCtrl: NavController) {
      this.antplus = (<any>window).antplus;
      this.antplus.searchDevices('HEARTRATE', (device) => {
      console.log(JSON.stringify(device));
      console.log("Ant ID=" + device.antDeviceNumber);
      this.SelectId = device.antDeviceNumber;
      },(error) => {
         console.log("Error Search="+error);
      });
    }

相关问题