【uniapp】组件注意事项

weex

  1. 文字写在text中
  2. <list>的子组件只能包括以下四种组件或是fix定位的组件 <cell> 用于定义列表中的子列表项,类似于html中的ul之于li。week会对 <cell> 进行高校的内存回收以达到更好的性能
    <header>:当<header>到达屏幕顶部时,吸附在屏幕顶部
    <refresh> 用于给列表添加下拉刷新的功能
    <loading> 用于与特性 <refresh>类似 用于给列表添加上拉加载更多的功能
  3. 图片要给指定宽高

效果图
在这里插入图片描述

<template>
	<list>
		<refresh style="height: 80px;" @refresh="refresh" @pullingdown="pullingdown" :display="show">
			<text>
				{{loadingtext}}
			</text>
		</refresh>
		<cell >
			<div style="height: 200px;border-width: 2px;border-style: solid;border-color: #007AFF;background-color: #4CD964;margin: 50px;"> 
				<text></text>
			</div>
		</cell>
		<header>
			<div style="height: 300px;background-color: #333333;">
			
			</div>
		</header>
		<cell v-for="(num,index) in lists" :key="index">
			<div style="height: 200px;border-width: 2px;border-style: solid;border-color: #007AFF;background-color: #4CD964;margin: 50px;"> 
				<text>{{num}}</text>
			</div>
		</cell>
		<loading @loading="onloading" :display="loadshow">
			<text style="display:flex;justify-content: center;width: 720px;">
				上拉加载更多
			</text>
		</loading>
	</list>
</template>
<script>
	export default {
	  data () {
	    return {
		  show:"hide",
		  loadshow:'hide',
		  loadingtext:'下拉可刷新',
	      lists: ['A', 'B', 'C', 'D', 'E'],
		  
	    }
	  },
	  methods:{
		  // 上拉加载事件
		  onloading(){
			  this.loadshow = 'show'
			  setTimeout(()=>{
				  this.lists=[...this.lists,...['a','b','c']]//解构赋值
				  this.loadshow = 'hide'
			  },2000)
		  },
		  //执行刷新
		  refresh(e){
			  this.show = 'show'
		  	this.loadingtext = '正在刷新..'
			setTimeout(()=>{
				this.show = 'hide'
				
				this.loadingtext = '下拉可刷新'
			},1500)
		  },
		  // 判断下拉刷新状态
		  pullingdown(e){
		  	// pullingDistance: 下拉的距离
		  	// viewHeight: refresh 组件高度
			if(e.pullingDistance > e.viewHeight){
				this.loadingtext = '释放就能刷新..'
			}else{
				this.loadingtext = '下拉可刷新'
			}
		  }
	  }
	}
</script>
<style src="@/common/common.css">

</style>
<style>

</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值