wx.chooseImage不执行?
发布于 4 年前 作者 dgong 5084 次浏览 来自 问答
methods: {
    getConfig() {   请求配置信息
      this.ajax({
        url"api/wechat/auth",
        method"POST",
        data: { urlwindow.location.href },
        successr => {
          this.config = r.data;
          this.wxConfig();
        }
      });
    },

wxConfig() {
      var that = this;
      console.log(that.config.signature);
      wx.config({  配置相关
        // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,测试完成后需要关闭。
        appId: that.config.appId, // 必填,公众号的唯一标识
        timestamp: that.config.timestamp, // 必填,生成签名的时间戳
        nonceStr: that.config.nonceStr, // 必填,生成签名的随机串
        signature: that.config.signature, // 必填,签名(加密后,下文有实现)
        jsApiList: that.config.jsApiList // 必填,需要使用的JS接口列表,开发文档上有所有接口名称,根据需要选用就好。
      });
      wx.error(function(res{
        alert("出错了:" + res.errMsg); //这个地方的好处就是wx.config配置错误,会弹出窗口哪里错误,然后根据微信文档查询即可。
      });
    },
upload() { 点击事件 调用wx.chooseImage没反应  能打印111
      var that = this;
      console.log(111);
      wx.chooseImage({
        count1// 默认9
        sizeType: ["original""compressed"], // 指定是原图还是压缩图,默认都有
        sourceType: ["album""camera"], // 指定来源是相册还是相机,默认都有
        successfunction(res{
          console.log(res);
}})
1 回复

有报错信息吗?

回到顶部