从vuex仓库获取数据,设置tab栏徽标
核心语法:
uni.setTabBarBadge({
index: 2,//索引
text: `${this.carttotal}`//显示文本
})
<script>
import {
mapState
} from "vuex"
export default {
data() {
return {}
},
computed: {
...mapState('cart', ['carttotal'])
},
onLoad() {
this.setbrage()
},
methods: {
setbrage() {
uni.setTabBarBadge({
index: 2,
text: `${this.carttotal}`
})
}
}
}
</script>