提交 0a33ce6d 编写于 作者: Q qiang

feat: App端增加方法 uni.onTabBarMidButtonTap

上级 057fb9c2
......@@ -115,7 +115,7 @@ const device = [
]
const keyboard = [
'hideKeyboard',
'hideKeyboard',
'onKeyboardHeightChange'
]
......@@ -138,6 +138,7 @@ const ui = [
'removeTabBarBadge',
'showTabBarRedDot',
'hideTabBarRedDot',
'onTabBarMidButtonTap',
'setBackgroundColor',
'setBackgroundTextStyle',
'createAnimation',
......@@ -209,4 +210,4 @@ const apis = [
...third
]
module.exports = apis
module.exports = apis
import {
isFn
} from 'uni-shared'
} from 'uni-shared'
const todoApis = Object.create(null)
const TODOS = [
'onTabBarMidButtonTap',
'subscribePush',
'unsubscribePush',
'onPush',
......@@ -29,4 +30,4 @@ TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name)
})
export default todoApis
export default todoApis
import {
onMethod,
invokeMethod
} from '../../platform'
import {
invoke
} from 'uni-core/service/bridge'
export function removeTabBarBadge ({
index
}) {
......@@ -20,4 +25,16 @@ export function showTabBarRedDot ({
})
}
export const hideTabBarRedDot = removeTabBarBadge
export const hideTabBarRedDot = removeTabBarBadge
const callbacks = []
onMethod('onTabBarMidButtonTap', res => {
callbacks.forEach(callbackId => {
invoke(callbackId, res)
})
})
export function onTabBarMidButtonTap (callbackId) {
callbacks.push(callbackId)
}
......@@ -3,6 +3,7 @@ import {
} from '../api/util'
import {
publish,
requireNativePlugin
} from '../bridge'
......@@ -102,6 +103,9 @@ export default {
tabBar && tabBar.onClick(({ index }) => {
clickCallback(config.list[index], index, true)
})
tabBar && tabBar.onMidButtonClick(() => {
publish('onTabBarMidButtonTap', {})
})
},
switchTab (page) {
const itemLength = config.list.length
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册