#uniapp#案例#滚动组件制造

在这里插入图片描述


<template>
	<view class="scroll">
		<scroll-view class="list-scroll" scroll-y>
			<view>
				<view v-for="i in 100">{{ i }} hello world</view>
			</view>
		</scroll-view>
	</view>
</template>

<style lang="scss">
.scroll {
	display: flex;
	border: 1px solid red;
	box-sizing: border-box;
	overflow: hidden;
	.list-scroll {
		height: 100%;
		display: flex;
		flex-direction: column;
	}
}
</style>






可以将内容抽取,改造成插槽


内容如下,动态插入 内容

<template>
	<view class="scroll">
		<scroll-view class="list-scroll" scroll-y>
			<view>
				<slot></slot>
			</view>
		</scroll-view>
	</view>
</template>

<style lang="scss">
.scroll {
	display: flex;
	border: 1px solid red;
	box-sizing: border-box;
	overflow: hidden;
	.list-scroll {
		height: 100%;
		display: flex;
		flex-direction: column;
	}
}
</style>

调用模板部分:

<template>
	<view id="flex-box">
		<view style="position: fixed;">hello</view>
		 
		 <about>
			 <view v-for="i in 100"> {{ i }} </view>
		 </about>
	</view>
</template>

<script>
	// import about from '@/pages/about/about'
	export default {
		
		data() {
			return {
				
			}
		} 
		 
	}
</script>

<style scoped lang="scss">
	 

</style>

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章