提交 b633f8f1 编写于 作者: L liuxiaohang 提交者: qiang

fix(h5): iconPath修改,兼容协议头和无协议情况

上级 87fd66f1
<template> <template>
<uni-tabbar <uni-tabbar
v-if="hasTabBar" v-if="hasTabBar"
v-show="showTabBar" v-show="showTabBar"
> >
<div <div
:style="{'flex-direction':direction==='vertical'?'column':'row',backgroundColor:tabBarOptions.backgroundColor}" :style="{'flex-direction':direction==='vertical'?'column':'row',backgroundColor:tabBarOptions.backgroundColor}"
class="uni-tabbar" class="uni-tabbar"
> >
<div <div
v-for="(item,index) in tabBarOptions.list" v-for="(item,index) in tabBarOptions.list"
:key="item.pagePath" :key="item.pagePath"
class="uni-tabbar__item" class="uni-tabbar__item"
@click="_switchTab(item,index)" @click="_switchTab(item,index)"
> >
<div class="uni-tabbar__bd"> <div class="uni-tabbar__bd">
<div <div
v-if="showIcon && item.iconPath" v-if="showIcon && item.iconPath"
:class="{'uni-tabbar__icon__diff':!item.text}" :class="{'uni-tabbar__icon__diff':!item.text}"
class="uni-tabbar__icon" class="uni-tabbar__icon"
> >
<img :src="_getRealPath(selectedIndex===index?item.selectedIconPath:item.iconPath)"> <img :src="_getRealPath(selectedIndex===index?item.selectedIconPath:item.iconPath)">
<div <div
v-if="item.redDot" v-if="item.redDot"
:class="{'uni-tabbar__badge':!!item.badge}" :class="{'uni-tabbar__badge':!!item.badge}"
class="uni-tabbar__reddot" class="uni-tabbar__reddot"
> >
{{ item.badge }} {{ item.badge }}
</div> </div>
</div> </div>
<div <div
v-if="item.text" v-if="item.text"
:style="{color:selectedIndex===index?tabBarOptions.selectedColor:tabBarOptions.color,fontSize:showIcon&&item.iconPath?'10px':'14px'}" :style="{color:selectedIndex===index?tabBarOptions.selectedColor:tabBarOptions.color,fontSize:showIcon&&item.iconPath?'10px':'14px'}"
class="uni-tabbar__label" class="uni-tabbar__label"
> >
{{ item.text }} {{ item.text }}
<div <div
v-if="item.redDot&&(!showIcon || !item.iconPath)" v-if="item.redDot&&(!showIcon || !item.iconPath)"
:class="{'uni-tabbar__badge':!!item.badge}" :class="{'uni-tabbar__badge':!!item.badge}"
class="uni-tabbar__reddot" class="uni-tabbar__reddot"
> >
{{ item.badge }} {{ item.badge }}
</div> </div>
...@@ -104,7 +104,9 @@ export default { ...@@ -104,7 +104,9 @@ export default {
}, },
methods: { methods: {
_getRealPath (filePath) { _getRealPath (filePath) {
if (filePath.indexOf('/') !== 0) { const SCHEME_RE = /^([a-z-]+:)?\/\//i
const DATA_RE = /^data:.*,.*/
if (!(SCHEME_RE.test(filePath) || DATA_RE.test(filePath)) && filePath.indexOf('/') !== 0) {
filePath = '/' + filePath filePath = '/' + filePath
} }
return getRealPath(filePath) return getRealPath(filePath)
...@@ -133,4 +135,4 @@ export default { ...@@ -133,4 +135,4 @@ export default {
</script> </script>
<style> <style>
</style> </style>
...@@ -228,6 +228,11 @@ export default { ...@@ -228,6 +228,11 @@ export default {
}, },
methods: { methods: {
_getRealPath (filePath) { _getRealPath (filePath) {
const SCHEME_RE = /^([a-z-]+:)?\/\//i
const DATA_RE = /^data:.*,.*/
if (!(SCHEME_RE.test(filePath) || DATA_RE.test(filePath)) && filePath.indexOf('/') !== 0) {
filePath = '/' + filePath
}
return getRealPath(filePath) return getRealPath(filePath)
}, },
_switchTab ({ _switchTab ({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册