dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.19k stars 3.64k forks source link

vue3 vite onPageScroll 方法无效 #3184

Closed sufuwang closed 2 years ago

sufuwang commented 2 years ago

问题描述 页面中使用 onPageScroll 方法无效,也不报错

复现步骤 npm 包信息如下

"dependencies": {
  "@dcloudio/uni-app": "3.0.0-alpha-3030720220111002",
  "@dcloudio/uni-app-plus": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-components": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-h5": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-alipay": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-baidu": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-lark": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-qq": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-mp-weixin": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3030320211225001",
  "@vitejs/plugin-vue": "2.0.0",
  "vue": "^3.2.22",
  "vue-i18n": "^9.1.9"
},
"devDependencies": {
  "@dcloudio/types": "^2.5.13",
  "@dcloudio/uni-automator": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-cli-i18n": "^2.0.0-32920210927001",
  "@dcloudio/uni-cli-shared": "3.0.0-alpha-3030320211225001",
  "@dcloudio/uni-ui": "^1.4.9",
  "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3030320211225001",
},

系统信息:

fxy060608 commented 2 years ago
  1. 更新到最新版本:3.0.0-alpha-3030720220111002
  2. 建议提问,尽可能描述清楚,比如直接贴代码,测试工程等
iceDays commented 2 years ago

https://github.com/dcloudio/uni-app/issues/3099#issuecomment-999315434

sufuwang commented 2 years ago
  1. 更新到最新版本:3.0.0-alpha-3030720220111002
  2. 建议提问,尽可能描述清楚,比如直接贴代码,测试工程等

更新版本后已经解决

sufuwang commented 2 years ago

#3099 (comment)

@iceDays 入口文件使用 globalThis 加载 onPageScroll 方法,页面中不需再引入

<script lang="ts" setup>
  onPageScroll(() => {});
</script>

@fxy060608 大佬这种方案,有什么问题吗

fxy060608 commented 2 years ago

#3099 (comment)

@iceDays 入口文件使用 globalThis 加载 onPageScroll 方法,页面中不需再引入

<script lang="ts" setup>
  onPageScroll(() => {});
</script>

@fxy060608 大佬这种方案,有什么问题吗

不是在入口地方使用 globalThis 加载 onPageScroll 方法

现在已经支持,直接在页面的 Githubissues.

  • Githubissues is a development platform for aggregating issues.