提交 7ef5d2cd 编写于 作者: D DCloud_LXH

feat(h5): tabBar set midButton

上级 ad024491
...@@ -301,7 +301,8 @@ export default { ...@@ -301,7 +301,8 @@ export default {
data () { data () {
return { return {
selectedIndex: 0, selectedIndex: 0,
visibleList: [] visibleList: [],
internalMidButton: {}
} }
}, },
computed: { computed: {
...@@ -345,6 +346,9 @@ export default { ...@@ -345,6 +346,9 @@ export default {
this._initVisibleList() this._initVisibleList()
this.setSelectedIndex() this.setSelectedIndex()
} }
},
midButton (config) {
this._initVisibleList()
} }
}, },
created () { created () {
...@@ -422,16 +426,16 @@ export default { ...@@ -422,16 +426,16 @@ export default {
const listLength = list.length const listLength = list.length
// 偶数则添加midButton // 偶数则添加midButton
if (listLength % 2 === 0 && isPlainObject(this.midButton)) { if (listLength % 2 === 0 && isPlainObject(this.midButton)) {
// 给midButton赋值默认值 this.internalMidButton = Object.assign(
const DefaultMidButton = { {
width: '50px', width: '50px',
height: '50px', height: '50px',
iconWidth: '24px' iconWidth: '24px'
} },
for (const key in DefaultMidButton) { this.internalMidButton,
this.midButton[key] = this.midButton[key] || DefaultMidButton[key] this.midButton
} )
list.splice(~~(listLength / 2), 0, Object.assign({}, this.midButton, { isMidButton: true })) list.splice(~~(listLength / 2), 0, Object.assign({}, this.internalMidButton, { isMidButton: true }))
} }
return list return list
}, },
......
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
const setTabBarItemProps = ['text', 'iconPath', 'iconfont', 'selectedIconPath', 'visible'] const setTabBarItemProps = ['text', 'iconPath', 'iconfont', 'selectedIconPath', 'visible']
const setTabBarStyleProps = ['color', 'selectedColor', 'backgroundColor', 'borderStyle'] const setTabBarStyleProps = ['color', 'selectedColor', 'backgroundColor', 'borderStyle', 'midButton']
const setTabBarBadgeProps = ['badge', 'redDot'] const setTabBarBadgeProps = ['badge', 'redDot']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册