diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index e421bd56694cf715c9f0c66e1c4fcfbca5777b70..79ee325f475e5aaf7734e2015448bb7330dc7843 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1376,21 +1376,45 @@ function isPage () { function initRefs (vm) { const mpInstance = vm.$scope; - mpInstance.selectAllComponents('.vue-ref', (components) => { - components.forEach(component => { - const ref = component.dataset.ref; - vm.$refs[ref] = component.$vm || component; - }); - }); - mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { - forComponents.forEach(component => { - const ref = component.dataset.ref; - if (!vm.$refs[ref]) { - vm.$refs[ref] = []; + /* eslint-disable no-undef */ + const minorVersion = parseInt(tt.getSystemInfoSync().SDKVersion.split('.')[1]); + if (minorVersion > 16) { + Object.defineProperty(vm, '$refs', { + get () { + const $refs = {}; + const components = mpInstance.selectAllComponents('.vue-ref'); + components.forEach(component => { + const ref = component.dataset.ref; + $refs[ref] = component.$vm || component; + }); + const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for'); + forComponents.forEach(component => { + const ref = component.dataset.ref; + if (!$refs[ref]) { + $refs[ref] = []; + } + $refs[ref].push(component.$vm || component); + }); + return $refs } - vm.$refs[ref].push(component.$vm || component); }); - }); + } else { + mpInstance.selectAllComponents('.vue-ref', (components) => { + components.forEach(component => { + const ref = component.dataset.ref; + vm.$refs[ref] = component.$vm || component; + }); + }); + mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { + forComponents.forEach(component => { + const ref = component.dataset.ref; + if (!vm.$refs[ref]) { + vm.$refs[ref] = []; + } + vm.$refs[ref].push(component.$vm || component); + }); + }); + } } const instances = Object.create(null);