vue注册组件

<template>
	<view>
		<scroll-view :scroll-into-view="'ss'+current" scroll-x="true" style="background-color: #007AFF;padding-top: 20px;">
			<view class="tabs">
				<text :id="'ss'+index" @click="chooseTab(index)" :class="{cur:current==index}" v-for="(item,index) in tabs" :key="index">{{item}}</text>
			</view>
		</scroll-view>
		<swiper :current="current" @change="changeSw" :style="{height:(wh-100)+'px'}">
			<swiper-item v-for="(item,index) in tabs" :key="index" >
				<xuezi v-if="current==0"></xuezi>
				<news v-if="current==1"></news>
				<meitu v-if="current==2"></meitu >
				<daiding v-if="current>2"></daiding>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
//注册组件
	import xuezi from "./subview/xuezi.vue"
	import meitu from "./subview/meitu.vue"
	import news from "./subview/news.vue"
	import daiding from "./subview/daiding.vue"
	export default {
		components:{xuezi,meitu,daiding,news },
		data() {
			return {
				tabs:['百姓商城','网易新闻','穿搭推荐','待定','待定','待定','待定'],
			    current:0,
				wh:uni.getSystemInfoSync().windowHeight
			}
		},
		
		methods: {
			changeSw(e){
				console.log(e)
				this.current=e.detail.current
			},
			chooseTab(index){
				console.log(index)
				this.current=index
			}
		}
	}
</script>

<style lang="scss">
  .tabs{
	  display: flex;
	  text{
		  padding: 10px;
		  white-space: nowrap;
		  color: white;
	  }
	  .cur{
		  color: orange;
		  border-bottom: 2px solid orange;
		  font-weight: bold;
	  }
  }
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值