{{item}}
_uniapp 自定义导航栏切换闪烁问题">
当前位置:   article > 正文

uni-app切换导航栏1_uniapp 自定义导航栏切换闪烁问题

uniapp 自定义导航栏切换闪烁问题

uni-app切换导航栏1

//tab.vue
<template>
	<div class="tabDemo w100 textc">
		<div class="fw500 ft28 c0" v-for="(item,index) in tabs" :key="index" @click="changeTab(index)">
			{{item}}
			<div class="line" v-if="tabIndex === index"></div>
		</div>
	</div>
	
</template>

<script>
	export default {
        name:'tab',
		props: { 
			tabs: Array,
			tabIndex: Number
		},
		data() {
			return {
			};
		},
		watch: {
			tabs(newVal) {
				this.tabs = newVal //对父组件传过来的值进行监听,如果改变也对子组件内部的值进行改变
			}
		},
		methods:{
			changeTab(index){
				console.log('tabIndex', this.tabIndex)
				this.$emit('tabsChange', index)
			}
		}
	}
</script>

<style scoped>
.tabDemo{
	height: 88px;
	background: #FFFFFF;
	display: flex;
	position: relative
}
div{
    position: relative;
    flex: 1;
    line-height: 100px;
    font-size: 28px;
    font-family: PingFangSC-Medium, PingFang SC;
    /* font-weight: 500; */
    color: #000000;
    font-weight: bold;
}
.line{
    position: absolute;
    bottom: 0;
    bottom: 0;
    width: 50px;
    height: 7px;
    background: #FF8C00;
    border-radius: 4px;
    left:50%;
    margin-left:-25px;
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
<template>
    <div id='Three'>
        <!-- 切换导航部分 -->
       	<Tab :tabs='tabs' :tabIndex='status' @tabsChange='tabsChange'></Tab>
    </div>
</template>
<script>
import Tab from './tab/tab'
export default {
   components:{
        Tab,
    },
    data() {
        return {
            status:0,
            tabs: ['未支付', '已结款', '全部'],
        };
    },
    methods:{
        tabsChange(value){
            console.log('更改tab', value)
            this.status = value;
        },
    }
}
</script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/594936
推荐阅读
相关标签