当前位置: 首页 > news >正文

uni-app 之 scroll-view和swiper

uni-app 之 scroll-view和swiper

<!-- vue2的<template>里必须要有一个盒子,不能有两个,这里的盒子就是 view-->
<template><view><navigator url="/pages/home/home"><button style="background: #ff00ff; color: aqua;">跳转到新页面</button></navigator><view>Vertical Scroll<text>\n纵向滚动</text></view><view @tap="goTop">点击这里返回顶部</view><view><scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-y" @scrolltoupper="upper"@scrolltolower="lower" @scroll="scroll"><view id="demo1" style="background: #fff000;" class="scroll-item-y 1">A</view><view id="demo2" style="background: #00ff00;" class="scroll-item-y 2">B</view><view id="demo3" style="background: #aa00aa;" class="scroll-item-y 3">C</view></scroll-view></view><view>Horizontal Scroll<text>\n横向滚动</text></view><view><scroll-view class="scroll-h" scroll-x="true"><view id="demo1" style="background: #fff000;" class="scroll-item-h 1">A</view><view id="demo2" style="background: #00ff00;" class="scroll-item-h 2">B</view><view id="demo3" style="background: #aa00aa;" class="scroll-item-h 3">C</view></scroll-view></view></view>
</template>

<script>export default {data() {return {scrollTop: 0,old: {scrollTop: 0}}},methods: {upper: function(e) {console.log(e)},lower: function(e) {console.log(e)},scroll: function(e) {console.log(e)this.old.scrollTop = e.detail.scrollTop},goTop: function(e) {// 解决view层不同步的问题this.scrollTop = this.old.scrollTopthis.$nextTick(function() {this.scrollTop = 0});uni.showToast({icon: "none",title: "纵向滚动 scrollTop 值已被修改为 0"})}}}
</script>

<style lang="scss">.scroll-y {height: 300rpx;.scroll-item-y {height: 200rpx;line-height: 200rpx;text-align: center; // 元素居中font-size: 36rpx;}}.scroll-h {white-space: nowrap;width: 100%;height: 300rpx;.scroll-item-h {display: inline-block;width: 80%;height: 100%;line-height: 300rpx;text-align: center; // 元素居中font-size: 36rpx;}}
</style>


swiper 轮播图

//indicator-dots="ture"小圆点,
//autoplay="ture"自动轮播,
//interval="1000"跳转时间,
//circular="ture"是否采用衔接滑动,即播放到末尾后重新回到开头

        <swiper style="width: 100%; height: 500rpx;" indicator-dots="ture" autoplay="ture" interval="1000"circular="ture"><swiper-item><view class="swiper-item 1">A西湖龙井</view><imagesrc="https://img2.baidu.com/it/u=2377761094,931944803&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"></image></swiper-item><swiper-item><view class="swiper-item 2" style="text-align: center;">B洞庭碧螺春</view><imagesrc="https://img0.baidu.com/it/u=1273610305,982475941&fm=253&fmt=auto&app=120&f=JPEG?w=501&h=500"></image></swiper-item><swiper-item><view class="swiper-item 3" style="text-align: right;">C信阳毛尖</view><image src="https://img2.baidu.com/it/u=769633489,863861704&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"></image></swiper-item></swiper>
http://www.lryc.cn/news/155405.html

相关文章:

  • Harmony网络请求工具类
  • 【Python 自动化】自媒体剪辑第一版·思路简述与技术方案
  • 【前端】webpack打包去除console.log
  • docker使用(二)提交到dockerhub springboot制作镜像
  • antd中Popover 气泡卡片样式修改
  • 3月面试华为被刷,准备半年,9月二战华为终于上岸,要个27K不过分吧?
  • Kali之BurpSuite_pro安装配置
  • 双指针算法总结
  • 开源照片管理服务LibrePhotos
  • Linux指令
  • 如何在Mac电脑上安装WeasyPrint:简单易懂的步骤
  • 手机电脑scoket通信 手机软件 APP inventor 服务端程序python
  • 软考高级之系统架构师之系统安全性和保密性设计
  • FPGA实现电机转速PID控制
  • C++中的volatile
  • 数学建模--一维插值法的多种插值方式的Python实现
  • 爱校对:让法律、医疗、教育行业的文本更加无懈可击
  • 使用pip下载第三方软件包报错超时处理方法
  • 计算古坐标——基于GPlates Web Service的坐标点重建
  • 智安网络|加强软件供应链安全保障:共同抵御威胁的关键路径
  • 华为Mate 60系列发售,北斗卫星通信技术进一步深入大众消费市场
  • Grad-CAM,即梯度加权类激活映射 (Gradient-weighted Class Activation Mapping)
  • 程序发布——使用pyinstaller打包识别程序为exe可执行文件 详解
  • Docker 使用
  • 电脑c盘变红满了怎么清理?4个方法轻松清理!
  • 【UE 材质】实现角度渐变材质、棋盘纹理材质
  • [深度学习]1. 深度学习知识点汇总
  • 鲁棒优化入门(6)—Matlab+Yalmip两阶段鲁棒优化通用编程指南(上)
  • golang通过gorm操作sqlite设置主键自增
  • 基于Spring Boot的企业门户网站设计与实现(Java+spring boot+MySQL)