提交 9ef5babd 编写于 作者: Q qiang

fix: 修复部分情况下获取 wxs 实例错误的问题 question/117097

上级 dee72508
......@@ -137,7 +137,7 @@ class ComponentDescriptor {
}
callMethod (funcName, args = {}) {
if (this.$vm[funcName]) {
if (funcName in this.$vm) {
this.$vm[funcName](JSON.parse(JSON.stringify(args)))
} else if (this.$vm._$id) {
UniViewJSBridge.publishHandler('onWxsInvokeCallMethod', {
......@@ -167,10 +167,11 @@ export function createComponentDescriptor (vm, isOwnerInstance = true) {
// ownerInstance 内置组件需要使用父 vm
vm = vm.$parent
}
if (vm && vm.$el) {
if (!vm.$el.__wxsComponentDescriptor) {
vm.$el.__wxsComponentDescriptor = new ComponentDescriptor(vm)
// 改为挂载到 vm 实例,不同 vm 实例的 $el 可能重复
if (vm) {
if (!('__wxsComponentDescriptor' in vm)) {
vm.__wxsComponentDescriptor = new ComponentDescriptor(vm)
}
return vm.$el.__wxsComponentDescriptor
return vm.__wxsComponentDescriptor
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册