<template>
<van-button round type="info" @click="switchFun">
<p class="" v-show="switchStatusNew">客源</p>
<p v-show="!switchStatusNew">房源</p>
</van-button>
</template>
<script>
data() {
return {
// 客源,房源切换
switchStatusNew: true,
};
},
created() {
this.switchStatusNew = this.$store.state.switchStatus;
},
</script>
判断Vuex传递过来的值的类型是否为Boolean。
console.log(typeof this.switchStatusNew);
如果不是Boolean,v-if是不会响应的。