小程序开发者工具中iphonex.js中的不完善代码
发布于 6 年前 作者 duming 12302 次浏览 来自 问答

控制台报错:Uncaught (in promise) TypeError: _this.set is not a function     at iphonex.js? [sm]:34。

代码:

var isIPhoneX = null;

function getIsIPhoneX() {

  return new Promise(function (resolve, reject) {

    if (isIPhoneX !== null) {

      resolve(isIPhoneX);

    } else {

      wx.getSystemInfo({

        success: function success(_ref) {

          var model = _ref.model,

              screenHeight = _ref.screenHeight;

          var iphoneX = /iphone x/i.test(model);

          var iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;

          isIPhoneX = iphoneX || iphoneNew;

          resolve(isIPhoneX);

        },

        fail: reject

      });

    }

  });

export var iphonex = Behavior({

  properties: {

    safeAreaInsetBottom: {

      type: Boolean,

      value: true

    }

  },

  created: function created() {

    var _this = this;

    getIsIPhoneX().then(function (isIPhoneX) {

      _this.set({ //<==就是这里有错!

        isIPhoneX: isIPhoneX

      });

    });

  }

});

1 回复

小程序不是setdata吗?

回到顶部