提交 b3e514c2 编写于 作者: d-u-a's avatar d-u-a

feat: H5 tabbar iconfont

上级 b7feb489
......@@ -36,13 +36,23 @@
:style="{height:height}"
>
<div
v-if="getIconPath(item,index) || item.iconPath || item.isMidButton"
v-if="getIconPath(item,index) || item.iconfont || item.iconPath || item.isMidButton"
:class="{'uni-tabbar__icon__diff':!item.text}"
class="uni-tabbar__icon"
:style="{width: iconWidth,height:iconWidth}"
>
>
<div
v-if="item.iconfont"
:style="{
color:selectedIndex === index ? selectedColor : color,
fontSize: item.iconfont.fontSize || fontSize
}"
class="uni-tabbar__iconfont"
>
{{ selectedIndex === index ? item.iconfont.selectedText : item.iconfont.text }}
</div>
<img
v-if="!item.isMidButton"
v-else-if="!item.isMidButton"
:src="_getRealPath(getIconPath(item,index))"
>
<div
......@@ -166,6 +176,10 @@
uni-tabbar .uni-tabbar__icon img {
width: 100%;
height: 100%;
}
uni-tabbar .uni-tabbar__iconfont {
font-family: 'UniTabbarIconFont';
}
uni-tabbar .uni-tabbar__label {
......@@ -219,10 +233,12 @@
<script>
import getRealPath from 'uni-platform/helpers/get-real-path'
import { isPlainObject } from 'uni-shared'
import { publish } from 'uni-platform/service/bridge'
import { publish } from 'uni-platform/service/bridge'
import { loadFontFace } from 'uni-core/view/bridge/subscribe/font'
function cssSupports (css) {
return window.CSS && CSS.supports && (CSS.supports(css) || CSS.supports.apply(CSS, css.split(':')))
}
}
const UNI_TABBAR_ICON_FONT = 'UniTabbarIconFont'
export default {
name: 'TabBar',
props: {
......@@ -247,6 +263,10 @@ export default {
borderStyle: {
type: String,
default: 'black'
},
iconfontSrc: {
type: String,
default: ''
},
list: {
type: Array,
......@@ -339,6 +359,12 @@ export default {
if (item.visible === undefined) {
this.$set(item, 'visible', true)
}
})
loadFontFace({
options: {
family: UNI_TABBAR_ICON_FONT,
source: `url("${this.iconfontSrc}")`
}
})
},
beforeCreate () {
......
......@@ -2,7 +2,7 @@ import {
setProperties
} from 'uni-shared'
const setTabBarItemProps = ['text', 'iconPath', 'selectedIconPath', 'visible']
const setTabBarItemProps = ['text', 'iconPath', 'iconfont', 'selectedIconPath', 'visible']
const setTabBarStyleProps = ['color', 'selectedColor', 'backgroundColor', 'borderStyle']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册