From cd6fe4bbe1690628b85ffb6503669d5823d73c94 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Sun, 25 Jul 2021 17:23:11 +0800 Subject: [PATCH] fix(h5): wxs --- packages/uni-core/src/view/plugin/componentWxs.ts | 15 +++++++-------- packages/uni-h5-vue/dist/vue.runtime.cjs.js | 5 +++-- .../uni-h5-vue/dist/vue.runtime.compat.cjs.js | 5 +++-- .../uni-h5-vue/dist/vue.runtime.compat.esm.js | 5 +++-- packages/uni-h5-vue/dist/vue.runtime.esm.js | 5 +++-- packages/uni-h5/dist/uni-h5.es.js | 8 ++++++-- .../src/configResolved/plugins/preVue.ts | 6 +++--- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/packages/uni-core/src/view/plugin/componentWxs.ts b/packages/uni-core/src/view/plugin/componentWxs.ts index ab44ea353..b6f6b4b2d 100644 --- a/packages/uni-core/src/view/plugin/componentWxs.ts +++ b/packages/uni-core/src/view/plugin/componentWxs.ts @@ -189,14 +189,13 @@ function createComponentDescriptor( vm: ComponentPublicInstance, isOwnerInstance = true ) { - if ( - isOwnerInstance && - vm && - vm.$options.name && - isBuiltInComponent(hyphenate(vm.$options.name)) - ) { - // ownerInstance 内置组件需要使用父 vm - vm = vm.$parent! + if (isOwnerInstance && vm) { + let componentName = vm.$options && vm.$options.name + while (componentName && isBuiltInComponent(hyphenate(componentName))) { + // ownerInstance 内置组件需要使用父 vm + vm = vm.$parent! + componentName = vm.$options && vm.$options.name + } } if (vm && vm.$el) { if (!vm.$el.__wxsComponentDescriptor) { diff --git a/packages/uni-h5-vue/dist/vue.runtime.cjs.js b/packages/uni-h5-vue/dist/vue.runtime.cjs.js index c6a80046e..6aa0f499e 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.cjs.js +++ b/packages/uni-h5-vue/dist/vue.runtime.cjs.js @@ -9146,8 +9146,9 @@ function patchWxs(el, rawName, nextValue, instance = null) { const proxy = instance.proxy; const name = rawName.split(':')[1]; el.__wxsWatches[rawName] = proxy.$watch(() => instance.attrs[name], (value, oldValue) => { - // TODO ownerInstance,instance - nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, true)); + nextTick(() => { + nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, false)); + }); }, { deep: true }); diff --git a/packages/uni-h5-vue/dist/vue.runtime.compat.cjs.js b/packages/uni-h5-vue/dist/vue.runtime.compat.cjs.js index f65b9a030..5799cfa2e 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.compat.cjs.js +++ b/packages/uni-h5-vue/dist/vue.runtime.compat.cjs.js @@ -11014,8 +11014,9 @@ function patchWxs(el, rawName, nextValue, instance = null) { const proxy = instance.proxy; const name = rawName.split(':')[1]; el.__wxsWatches[rawName] = proxy.$watch(() => instance.attrs[name], (value, oldValue) => { - // TODO ownerInstance,instance - nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, true)); + nextTick(() => { + nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, false)); + }); }, { deep: true }); diff --git a/packages/uni-h5-vue/dist/vue.runtime.compat.esm.js b/packages/uni-h5-vue/dist/vue.runtime.compat.esm.js index c18fe5db5..f0b547d1d 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.compat.esm.js +++ b/packages/uni-h5-vue/dist/vue.runtime.compat.esm.js @@ -11070,8 +11070,9 @@ function patchWxs(el, rawName, nextValue, instance = null) { const proxy = instance.proxy; const name = rawName.split(':')[1]; el.__wxsWatches[rawName] = proxy.$watch(() => instance.attrs[name], (value, oldValue) => { - // TODO ownerInstance,instance - nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, true)); + nextTick(() => { + nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, false)); + }); }, { deep: true }); diff --git a/packages/uni-h5-vue/dist/vue.runtime.esm.js b/packages/uni-h5-vue/dist/vue.runtime.esm.js index be41a7e1f..d733981bc 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.esm.js +++ b/packages/uni-h5-vue/dist/vue.runtime.esm.js @@ -9198,8 +9198,9 @@ function patchWxs(el, rawName, nextValue, instance = null) { const proxy = instance.proxy; const name = rawName.split(':')[1]; el.__wxsWatches[rawName] = proxy.$watch(() => instance.attrs[name], (value, oldValue) => { - // TODO ownerInstance,instance - nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, true)); + nextTick(() => { + nextValue(value, oldValue, proxy.$gcd(proxy, true), proxy.$gcd(proxy, false)); + }); }, { deep: true }); diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 6b91b95cd..594fadeee 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -1323,8 +1323,12 @@ class ComponentDescriptor { } } function createComponentDescriptor(vm, isOwnerInstance = true) { - if (isOwnerInstance && vm && vm.$options.name && isBuiltInComponent(hyphenate(vm.$options.name))) { - vm = vm.$parent; + if (isOwnerInstance && vm) { + let componentName = vm.$options && vm.$options.name; + while (componentName && isBuiltInComponent(hyphenate(componentName))) { + vm = vm.$parent; + componentName = vm.$options && vm.$options.name; + } } if (vm && vm.$el) { if (!vm.$el.__wxsComponentDescriptor) { diff --git a/packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts b/packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts index 2f451d555..114abf173 100644 --- a/packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts +++ b/packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts @@ -55,9 +55,9 @@ export function uniPreVuePlugin(): Plugin { if (hasWxs) { code = normalizeWxsCode(ast, code) } - if (errors.length) { - this.error(errors.join('\n')) - } + // if (errors.length) { + // this.error(errors.join('\n')) + // } sourceToSFC.set(sourceKey, code) return code // 暂不提供sourcemap,意义不大 }, -- GitLab