k***@qq.com
k***@qq.com
  • 发布:2021-10-15 12:10
  • 更新:2022-09-16 10:12
  • 阅读:1361

uniapp 支付宝 ref 获取组件实例

分类:uni-app

大佬们好,uniapp编译到支付宝

<flowexchange @onCounterFlowExchange="onCounterExchange" v-if='uid' ref="saveRefFlowExchange" :uid="uid" :channel="flowchanel"></flowexchange>  

编译后  
 <block a:if="{{uid}}">  
      <flowexchange vue-id="2acd03d5-1" uid="{{uid}}" channel="{{flowchanel}}" ref="__r" data-ref="saveRefFlowExchange"   
        data-event-opts="{{[['^onCounterFlowExchange',[['onCounterExchange']]]]}}" data-com-type="wx" onOnCounterFlowExchange="__e"   
        onVueInit="__l"></flowexchange></block>

然后支付宝报错
TypeError: Cannot read property 'data-com-type' of undefined
Please check your component:

这种问题怎么查看究竟是哪里出问题了呢?
烦请大佬帮助一下!

2021-10-15 12:10 负责人:无 分享
已邀请:
k***@qq.com

k***@qq.com (作者)

编译后的data-com-type="wx" 这是什么鬼?
vendor.js 文件中是这样

function handleRef(ref) {  
  if (!ref) {  
    return;  
  }  
  if (ref.props['data-com-type'] === 'wx') {  
    var eventProps = {};  
    var refProps = ref.props;  
    // 初始化支付宝小程序组件事件  
    Object.keys(refProps).forEach(function (key) {  
      var handler = refProps[key];  
      var res = key.match(/^on([A-Z])(\S*)/);  
      if (res && typeof handler === 'function' && handler.name === 'bound handleEvent') {  
        var event = res && res[1].toLowerCase() + res[2];  
        refProps[key] = eventProps[key] = function () {  
          var props = Object.assign({}, refProps);  
          props[key] = handler;  
          // 由于支付宝事件可能包含多个参数,不使用微信小程序事件格式  
          delete props['data-com-type'];  
          triggerEvent.bind({ props: props })(event, {  
            __args__: Array.prototype.slice.call(arguments) });  

        };  
      }  
    });  
    // 处理 props 重写  
    Object.defineProperty(ref, 'props', {  
      get: function get() {  
        return refProps;  
      },  
      set: function set(value) {  
        refProps = Object.assign(value, eventProps);  
      } });  

  }
  • 1***@qq.com

    请问一下这个问题解决了么

    2022-09-15 16:14

  • 1***@qq.com

    回复 1***@qq.com: 升级一下uni试试

    2022-09-16 15:23

k***@qq.com

k***@qq.com (作者)

顶一下

k***@qq.com

k***@qq.com (作者)

给各位大佬跪了 - -

1***@qq.com

1***@qq.com

有解决么

要回复问题请先登录注册