自定义header

<template>
	<view class="headbox">
		<image class="bankicon" src="@/static/image/head/bankicon.png" @click="bank()" mode=""></image>
		<text class="titlecls">{{ title }}</text>
		<text></text>
	</view>
</template>

<script>
	export default {
	  props: ['title'],// 接收传入的标题数据
		methods: {
			// 返回
			bank() {
				uni.navigateBack({
					delta: 1  //返回上一页
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.headbox {
		width: 100%;
		height: 166rpx;
		background-image: url(@/static/image/head/headbg.png);
		background-repeat: no-repeat;
		background-size: cover;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.bankicon {
			width: 80rpx;
			height: 88rpx;
			margin-top: 70rpx;
		}
		.titlecls {
			font-size: 34rpx;
			color: #fff;
			font-weight: bold;
			margin-top: 70rpx;
			margin-left: -7%;
		}
	}
</style>

在main.js里引入

import Header from '@/components/head/index.vue'; // 引入Header组件

Vue.component('Header',Header)

在页面直接使用

<Header title="实时数据"></Header>

  • 16
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
SmartRefreshLayout是一个很棒的下拉刷新、上拉加载更多的框架,它支持自定义Header和Footer来满足不同的需求。下面是自定义Header的步骤: 1. 创建一个类,继承自RefreshHeader或者继承自它的子类,比如BezierRadarHeader或者FalsifyHeader等。 2. 实现RefreshHeader的必要方法,onInitialized、onPullingDown、onReleasing和onRefresh等。其中,onInitialized方法用于初始化Header,onPullingDown方法用于下拉过程的动画,onReleasing方法用于松手后Header的动画,onRefresh方法用于进行数据加载。 3. 在布局文件中引入自定义Header,使用自定义的类名即可。注意,Header的高度需要根据实际情况进行设置,可以使用dp或者px单位。 4. 在代码中使用SmartRefreshLayout的setRefreshHeader方法来设置自定义Header。 下面是一个简单的示例代码: ``` public class MyCustomHeader extends RefreshHeader { @Override public void onInitialized(@NonNull RefreshKernel kernel, int height, int extendHeight) { // 初始化Header } @Override public void onPullingDown(float percent, int offset, int height, int extendHeight) { // 下拉过程的动画 } @Override public void onReleasing(float percent, int offset, int height, int extendHeight) { // 松手后Header的动画 } @Override public void onRefresh(@NonNull RefreshLayout refreshLayout) { // 进行数据加载 } } // 在布局文件中引入自定义Header <com.scwang.smartrefresh.layout.SmartRefreshLayout ... > <com.example.MyCustomHeader android:layout_width="match_parent" android:layout_height="100dp"/> </com.scwang.smartrefresh.layout.SmartRefreshLayout> // 在代码中设置自定义Header SmartRefreshLayout refreshLayout = findViewById(R.id.refreshLayout); refreshLayout.setRefreshHeader(new MyCustomHeader()); ``` 注意,自定义Header的实现需要根据实际需求进行调整,上述代码仅供参考。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值