Skip to content

Commit

Permalink
fix(taro): 修复快应用下拉刷新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent de5dc7b commit 5a7638e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
11 changes: 9 additions & 2 deletions packages/taro-components-qa/src/components/taro-page/index.ux
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@

<script>
import Taro from '@tarojs/taro-quickapp'

const appGlobal = global || {}
let globalRef = Object.getPrototypeOf(appGlobal) || appGlobal
if (!Object.keys(appGlobal).length) {
globalRef = Object.getPrototypeOf(globalRef)
}
globalRef.eventCenter = Taro.eventCenter
function addLeadingSlash (str) {
return str[0] === '/' ? str : `/${str}`
}
Expand Down Expand Up @@ -102,10 +109,10 @@
},

onInit () {
Taro.eventCenter.on('TaroPage:stopPullDownRefresh', () => {
globalRef.eventCenter.on('TaroPage:stopPullDownRefresh', () => {
this.isPageRefreshing = false
})
Taro.eventCenter.on('TaroPage:startPullDownRefresh', () => {
globalRef.eventCenter.on('TaroPage:startPullDownRefresh', () => {
this.isPageRefreshing = true
})
this.setTabBarData()
Expand Down
1 change: 0 additions & 1 deletion packages/taro-mini-runner/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export const CONFIG_MAP = {
onReachBottomDistance: false,
backgroundColorBottom: false,
backgroundColorTop: false,
enablePullDownRefresh: false,
navigationStyle: 'navigationStyle'
},
[BUILD_TYPES.QQ]: {
Expand Down
11 changes: 5 additions & 6 deletions packages/taro-quickapp/src/api/interactive/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import prompt from '@system.prompt'
import {
eventCenter
} from '@tarojs/taro'

import appGlobal from '../../global'

export function showToast (options = {}) {
const { title = '', duration = 1500, success, complete, fail } = options
Expand Down Expand Up @@ -128,7 +127,7 @@ function setNavigationBar (params, fnName) {
const res = { errMsg: `${fnName}: ok` }
return new Promise((resolve, reject) => {
try {
eventCenter.trigger('TaroEvent:setNavigationBar', params)
appGlobal.eventCenter.trigger('TaroEvent:setNavigationBar', params)
success && success(res)
complete && complete(res)
resolve(res)
Expand All @@ -154,7 +153,7 @@ export function startPullDownRefresh (options = {}) {
const res = { errMsg: `startPullDownRefresh: ok` }
return new Promise((resolve, reject) => {
try {
eventCenter.trigger('TaroPage:startPullDownRefresh')
appGlobal.eventCenter.trigger('TaroPage:startPullDownRefresh')
success && success(res)
complete && complete(res)
resolve(res)
Expand All @@ -172,7 +171,7 @@ export function stopPullDownRefresh (options = {}) {
const res = { errMsg: `stopPullDownRefresh: ok` }
return new Promise((resolve, reject) => {
try {
eventCenter.trigger('TaroPage:stopPullDownRefresh')
appGlobal.eventCenter.trigger('TaroPage:stopPullDownRefresh')
success && success(res)
complete && complete(res)
resolve(res)
Expand Down

0 comments on commit 5a7638e

Please sign in to comment.