html52.com
我爱小程序-开发者交流社区

TypeScript开发,真机调试时,App()不被调用

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 工具 8.0.15 2.20.0

开放者工具版本:1.05.2110110

按向导创建项目,语言选择typescript,发现真机调试时,在页面里调用getApp()返回undefined

语言选择js,则正常

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    canIUseGetUserProfile: false,
    canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs',
    })
  },
  onLoad() {
    console.log('---------index.onLoad---------')
    console.log(getApp<IAppOption>())
    // @ts-ignore
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
  },

: true
      })
    }
  },

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付