首页 > 其他分享 >父组件传子组件参数限制String类型

父组件传子组件参数限制String类型

时间:2022-11-23 22:59:43浏览次数:46  
标签:bar String height 参数 tab 组件 path

 

 

<template>
  <div class="tab-bar-item" @click="itemClick">
    <div v-if="!isActive"><slot name="item-icon"></slot></div>
    <div v-else><slot name="item-icon-active"></slot></div>
    <div :class="{active: isActive}"><slot name="item-text"></slot></div>
  </div>
</template>

<script>
export default {
    name: "TabBarItem",
    props:{
      path: String
    },
    data(){
        return{
            isActive: false
        }
    },
    methods: {
      itemClick(index){
        this.$router.push(this.path).catch(err => {});
      }
    }
}
</script>

<style>
.tab-bar-item{
  flex: 1;
  text-align: center;
  height: 49px;
}
.tab-bar-item img{
    width: 20px;
    height: 20px;
}
.active{
    color: red;
}
</style>

  

标签:bar,String,height,参数,tab,组件,path
From: https://www.cnblogs.com/ixtao/p/16920427.html

相关文章