收藏
回答

NodesRef.fields在真机报createView of undefined?

wx.createSelectorQuery().in(this).select(`#customMap`).fields({

      node: true,

      rect: true

    }, res => {

      console.log(res.node)

    }).exec()

这个api在在开发者工具上 还有手机预览模式有回调 正常调用 然而在真机调试却报一个错 如果这个api是直接在页面使用 就没报错 真机也可以拿到回调 但是在组件内部使用就报错 canvas不加type=2d就没问题 可以获取到一部分数据 但是加了就报错

最后一次编辑于  2020-10-17
回答关注问题邀请回答
收藏

6 个回答

  • 今 朝
    今 朝
    2020-12-16

    请问这个问题解决了吗?如果上线了会不会影响功能

    2020-12-16
    有用 1
    回复
  • 慕鹿客服
    慕鹿客服
    2021-02-07

    解决了吗

    2021-02-07
    有用
    回复 1
    • Vee
      Vee
      发表于移动端
      2021-03-25
      没解决,使用的内嵌h5
      2021-03-25
      回复
  • iman¹²³
    iman¹²³
    2020-12-29

    我集成 https://github.com/chartjs/Chart.js 的时候也遇到了相同的问题,模拟器上预览没有问题,但是真机预览或调试就报这个错,使用的基础库是2.14.1,也试了低版本的几个库,也是报错(错误不同)

    我的代码如下:

    const app = getApp()
    const Chart = require('../package/dist/Chart.bundle');
    
    
    Chart.helpers.getStyle = function (el, property{
      // return el.currentStyle ?
      //   el.currentStyle[property] :
      //   document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
      console.info(`getStyle(${el}${property})`);
      return 0;
    };
    Chart.helpers._calculatePadding = function (container, padding, parentDimension{
      // padding = helpers$1.getStyle(container, padding);
      // return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 10) / 100 : parseInt(padding, 10);
      console.info(`_calculatePadding(${container}${padding}${parentDimension})`);
      return 0;
    };
    Chart.helpers.getConstraintWidth = function (domNode{
      // return getConstraintDimension(domNode, 'max-width', 'clientWidth');
      console.info(`getConstraintWidth(${domNode})`);
      return 350;
    };
    
    
    const data = {
      labels: ['Red''Blue''Yellow''Green''Purple''Orange'],
      datasets: [{
        label'# of Votes',
        data: [12193523],
        backgroundColor: [
          'rgba(255, 99, 132, 0.2)',
          'rgba(54, 162, 235, 0.2)',
          'rgba(255, 206, 86, 0.2)',
          'rgba(75, 192, 192, 0.2)',
          'rgba(153, 102, 255, 0.2)',
          'rgba(255, 159, 64, 0.2)'
        ],
        borderColor: [
          'rgba(255, 99, 132, 1)',
          'rgba(54, 162, 235, 1)',
          'rgba(255, 206, 86, 1)',
          'rgba(75, 192, 192, 1)',
          'rgba(153, 102, 255, 1)',
          'rgba(255, 159, 64, 1)'
        ],
        borderWidth1
      }]
    };
    
    
    Page({
      data: {},
    
    
      onLoadfunction () {
        this.position = {
          x150,
          y150,
          vx2,
          vy2
        }
        this.x = -100
    
    
        // 通过 SelectorQuery 获取 Canvas 节点
        wx.createSelectorQuery()
          .select('#canvas')
          .fields({
            nodetrue,
          })
          .exec(this.init.bind(this))
      },
    
    
      init(res) {
        const canvas = res[0].node
        const ctx = canvas.getContext('2d')
    
    
        var myChart = new Chart(ctx, {
          type'pie',
          data,
          options: {
            scales: {
              yAxes: [{
                ticks: {
                  beginAtZerotrue
                }
              }]
            },
          }
        });
    
    
      },
    
    
    })
    
    
    
    2020-12-29
    有用
    回复
  • 阿秋
    阿秋
    2020-12-21

    楼主解决了吗,我现在也是报这个

    2020-12-21
    有用
    回复
  • Vee
    Vee
    2020-10-17

    如果官方不支持canvas 2d真机调试 那请问如何进行真机调试 比如双指缩放之类的

    2020-10-17
    有用
    回复
  • Admin ²º²³
    Admin ²º²³
    2020-10-17

    开发者工具版本多少?

    下载最新版本试试:

    开发版 Nightly Build 更新日志 | 微信开放文档

    https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html

    如果还有问题,可能是不支持真机调试,以手机实际效果为准。

    2020-10-17
    有用
    回复 2
    • Vee
      Vee
      2020-10-17
      是用的2.13.1的调试基础库
      2020-10-17
      1
      回复
    • Vee
      Vee
      2020-10-17
      2020-10-17
      回复
登录 后发表内容
问题标签