uniapp点击导航栏,显示页面(动态渲染)

1.效果图展示(点击有效果且显示不同页面)

2. hrml代码   tab_itmbot所属标签表示下划线

              <view class="tab">
					<view :class="activeone"  @click="chenked(1)">
						<view class="tab_itemtitle">全部</view>
						<view class="tab_itembot"></view>
					</view>
					<view :class="activetwo"  @click="chenked(2)">
						<view class="tab_itemtitle" >待支付</view>
						<view class="tab_itembot"></view>
					</view>
					<view :class="activethree"  @click="chenked(3)">
						<view class="tab_itemtitle" >待发货</view>
						<view class="tab_itembot"></view>
					</view>
					<view :class="activefour"  @click="chenked(4)">
						<view class="tab_itemtitle">已发货</view>
						<view class="tab_itembot"></view>
					</view>
					<view :class="activefive"  @click="chenked(5)">
						<view class="tab_itemtitle" >已完成</view>
						<view class="tab_itembot"></view>
					</view>
				</view>

3.js代码  

包括组件引入,注册

注意:在conponents里面注册时,命名必须用小驼峰注册法:

即当标识符是一个单词的时候首字母小写

    当标识符是多个单词的时候首字母小写,其他单词首字母大写

<script>
	import pagea from "@/components/pageone/pageone.vue"
	import pageb from "@/components/pagetwo/pagetwo.vue"
	import pagec from "@/components/pagethree/pagethree.vue"
	import paged from "@/components/pagefour/pagefour.vue"
	import pagee from "@/components/pagefive/pagefive.vue"
	export default {
		components:{
			pagea,
			pageb,
			pagec,
			paged,
			pagee
		},
		data() {
			return {
				isActive: 1
			};
		},
		computed:{
				activeone() {
							return this.isActive==1?'active':'activeone'
						},                                          
			    activetwo() {                                         
							return this.isActive==2?'active':'activeone'
						},                                          
			    activethree() {                                         
							return this.isActive==3?'active':'activeone'
						},                                          
			    activefour() {                                         
							return this.isActive==4?'active':'activeone'
						},                                          
				activefive() {                                         
							return this.isActive==5?'active':'activeone'
						},
		},
		methods: {
					chenked(type) {
									this.isActive = type
								}
					}
		
	}
</script>

4.scss代码,注意要使用scss的页面

<style lang="scss">

	.tab {
			display: flex;
			width: 750rpx;
			align-items: center;
			height: 100rpx;
			background-color: #fff;
			// 选中的样式
			.active {
				height:50px;
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-left: 50rpx;
				margin-top: 40rpx;
				.tab_itemtitle {
					text-align: center;
					height: 48rpx;
					font-size: 34rpx;
					font-weight: bold;
					color: #EE2747;
					line-height: 40rpx;
				}
				.tab_itembot {
					width: 43rpx;
					height: 6rpx;
					background: #EE2747;
					border-radius: 5rpx;
					margin-top: 5rpx;
				}
			}
			// 未选中的样式
			.activeone{
				height:50px ;
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-left: 50rpx;
				margin-top: 40rpx;
				.tab_itemtitle {
				    height: 45rpx;
				    font-size: 33rpx;
				    font-weight: 500;
				    color: #666;
				    line-height: 38rpx;
					text-align: center;
				}
				
			}
			
		}

</style>

5.使用组件(组件里面写页面的具体内容)

<pagea v-if="isActive==1"></pagea>
<pageb v-if="isActive==2"></pageb>
<pagec v-if="isActive==3"></pagec>
<paged v-if="isActive==4"></paged>
<pagee v-if="isActive==5"></pagee>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值