Closed lhsxyzj closed 2 years ago
问题描述 项目编译成支付宝小程序插件,uni中hideLoading、getStorageInfoSync函数为undefined 在非页面组件中的子组件上使用ref,编译报错TypeError: Cannot read property '$refs' of undefined
复现步骤 [复现问题的步骤]
"uni-app": { "scripts": { "plugin-alipay": { "title": "支付宝小程序插件", "env": { "UNI_PLATFORM": "mp-alipay" }, "define": { "PLUGIN-ALIPAY": true } } } }
console.log('uni.hideLoading: ', uni.hideLoading)
组件
<test-child ref="child" /> <script> import TestChild from "./TestChild"; export default { name: "TestComponent", components: {TestChild} } </script>
子组件
<div>child</div> <script> export default { name: "TestChild" } </script>
实际结果
系统信息: Environment Info:
System: OS: Windows 10 CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz Binaries: Node: 14.15.1 - ~\AppData\Local\Temp\yarn--1636181296557-0.1564896318566471\node.CMD Yarn: 1.22.5 - ~\AppData\Local\Temp\yarn--1636181296557-0.1564896318566471\yarn.CMD npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.19041.1266.0 npmPackages: @dcloudio/types: => 2.5.12 @dcloudio/uni-app-plus: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-app-plus-nvue: 0.0.1 @dcloudio/uni-app-plus-nvue-v8: 0.0.1 @dcloudio/uni-automator: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-cli-i18n: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-cli-shared: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-h5: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-helper-json: => 1.0.13 @dcloudio/uni-i18n: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-migration: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-360: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-alipay: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-baidu: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-kuaishou: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-qq: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-toutiao: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-vue: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-weixin: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-quickapp-native: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-quickapp-webview: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-stat: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-template-compiler: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-ui: ^1.4.6 => 1.4.6 @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/vue-cli-plugin-uni: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/webpack-uni-mp-loader: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/webpack-uni-nvue-loader: 0.0.1 @dcloudio/webpack-uni-pages-loader: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @hap-toolkit/dsl-vue: 0.6.13 @vue/babel-helper-vue-jsx-merge-props: 1.2.1 @vue/babel-helper-vue-transform-on: 1.0.2 @vue/babel-plugin-jsx: 1.1.1 @vue/babel-plugin-transform-vue-jsx: 1.2.1 @vue/babel-preset-app: 4.5.15 @vue/babel-preset-jsx: 1.2.4 @vue/babel-sugar-composition-api-inject-h: 1.2.1 @vue/babel-sugar-composition-api-render-instance: 1.2.4 @vue/babel-sugar-functional-vue: 1.2.2 @vue/babel-sugar-inject-h: 1.2.2 @vue/babel-sugar-v-model: 1.2.3 @vue/babel-sugar-v-on: 1.2.3 @vue/cli-overlay: 4.5.15 @vue/cli-plugin-babel: ~4.5.0 => 4.5.15 @vue/cli-plugin-router: 4.5.15 @vue/cli-plugin-vuex: 4.5.15 @vue/cli-service: ~4.5.0 => 4.5.15 @vue/cli-shared-utils: 4.5.15 @vue/component-compiler-utils: 3.3.0 (3.3.0) @vue/devtools-api: 6.0.0-beta.15 @vue/preload-webpack-plugin: 1.1.2 @vue/shared: ^3.0.0 => 3.2.21 @vue/web-component-wrapper: 1.3.0 mpvue-page-factory: 1.0.1 mpvue-template-compiler: 1.0.13 uni-h5-vue: 2.6.10 uni-mp-vue: 2.6.10 vue: ^2.6.11 => 2.6.14 vue-hot-reload-api: 2.3.4 vue-loader: 15.9.8 (16.8.2, 15.9.8) vue-router: 3.0.1 vue-style-loader: 4.1.3 (4.1.3) vue-template-compiler: ^2.6.11 => 2.6.14 (2.6.14) vue-template-es2015-compiler: 1.9.1 vue3: 1.0.0 vuex: ^3.2.0 => 3.6.2 (3.6.2) npmGlobalPackages: @vue/cli: Not Found
补充信息 [可选] [根据你的分析,出现这个问题的原因可能在哪里?]
使用的基础库版本是多少?在微信小程序插件中表现是否正常?
同样遇到这个问题了。
是不是因为这个方法忘记写了?
https://github.com/dcloudio/uni-app/blob/d367dd8a53f047915340cca4a6c8a251f8d7a10d/src/platforms/mp-alipay/runtime/wrapper/util.js#L25
index.zip
下个版本解决。
临时解决方案:将附件替换至 项目根目录\node_modules\@dcloudio\uni-mp-alipay\dist 重新编译支付宝小程序插件即可
项目根目录\node_modules\@dcloudio\uni-mp-alipay\dist
问题描述 项目编译成支付宝小程序插件,uni中hideLoading、getStorageInfoSync函数为undefined 在非页面组件中的子组件上使用ref,编译报错TypeError: Cannot read property '$refs' of undefined
复现步骤 [复现问题的步骤]
组件
子组件
实际结果
系统信息: Environment Info:
System: OS: Windows 10 CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz Binaries: Node: 14.15.1 - ~\AppData\Local\Temp\yarn--1636181296557-0.1564896318566471\node.CMD Yarn: 1.22.5 - ~\AppData\Local\Temp\yarn--1636181296557-0.1564896318566471\yarn.CMD npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.19041.1266.0 npmPackages: @dcloudio/types: => 2.5.12 @dcloudio/uni-app-plus: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-app-plus-nvue: 0.0.1 @dcloudio/uni-app-plus-nvue-v8: 0.0.1 @dcloudio/uni-automator: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-cli-i18n: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-cli-shared: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-h5: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-helper-json: => 1.0.13 @dcloudio/uni-i18n: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-migration: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-360: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-alipay: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-baidu: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-kuaishou: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-qq: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-toutiao: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-vue: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-mp-weixin: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-quickapp-native: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-quickapp-webview: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-stat: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-template-compiler: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/uni-ui: ^1.4.6 => 1.4.6 @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/vue-cli-plugin-uni: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/webpack-uni-mp-loader: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @dcloudio/webpack-uni-nvue-loader: 0.0.1 @dcloudio/webpack-uni-pages-loader: ^2.0.0-32920210927002 => 2.0.0-32920211029001 @hap-toolkit/dsl-vue: 0.6.13 @vue/babel-helper-vue-jsx-merge-props: 1.2.1 @vue/babel-helper-vue-transform-on: 1.0.2 @vue/babel-plugin-jsx: 1.1.1 @vue/babel-plugin-transform-vue-jsx: 1.2.1 @vue/babel-preset-app: 4.5.15 @vue/babel-preset-jsx: 1.2.4 @vue/babel-sugar-composition-api-inject-h: 1.2.1 @vue/babel-sugar-composition-api-render-instance: 1.2.4 @vue/babel-sugar-functional-vue: 1.2.2 @vue/babel-sugar-inject-h: 1.2.2 @vue/babel-sugar-v-model: 1.2.3 @vue/babel-sugar-v-on: 1.2.3 @vue/cli-overlay: 4.5.15 @vue/cli-plugin-babel: ~4.5.0 => 4.5.15 @vue/cli-plugin-router: 4.5.15 @vue/cli-plugin-vuex: 4.5.15 @vue/cli-service: ~4.5.0 => 4.5.15 @vue/cli-shared-utils: 4.5.15 @vue/component-compiler-utils: 3.3.0 (3.3.0) @vue/devtools-api: 6.0.0-beta.15 @vue/preload-webpack-plugin: 1.1.2 @vue/shared: ^3.0.0 => 3.2.21 @vue/web-component-wrapper: 1.3.0 mpvue-page-factory: 1.0.1 mpvue-template-compiler: 1.0.13 uni-h5-vue: 2.6.10 uni-mp-vue: 2.6.10 vue: ^2.6.11 => 2.6.14 vue-hot-reload-api: 2.3.4 vue-loader: 15.9.8 (16.8.2, 15.9.8) vue-router: 3.0.1 vue-style-loader: 4.1.3 (4.1.3) vue-template-compiler: ^2.6.11 => 2.6.14 (2.6.14) vue-template-es2015-compiler: 1.9.1 vue3: 1.0.0 vuex: ^3.2.0 => 3.6.2 (3.6.2) npmGlobalPackages: @vue/cli: Not Found
补充信息 [可选] [根据你的分析,出现这个问题的原因可能在哪里?]