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

UNIAPP实战项目笔记3 Swiper部分开发

推荐:

  1. 顶部滑动导航
  2. swiper
    • 名称: IndexSwiper
    • 封装: 是

swiper的坑:

  1. 组件名称为swiper.vue或者 Swiper.vue, 在传递数据的时候有可能图片就不见了
  2. 改变图片的大小,最好用rpx为单位,兼容性好一些
  3. 本身swiper是有150px的默认高度,app中需要给吧默认高度的时候加入:
        swiper{
            width:100%;
            height:400rpx;
        }
    
  • 新建一个组件 indexSwiper.vue 在components目录下
        <template>
            <view class="swiperview">
                <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
                    <swiper-item>
                        <view class="swiper-item">
                            <image class="swiper-img" src="/static/img/b3.jpg" mode=""></image>
                        </view>
                    </swiper-item>
                    <swiper-item>
                        <view class="swiper-item">
                            <image class="swiper-img" src="/static/img/b3.jpg" mode=""></image>
                        </view>
                    </swiper-item>
                    <swiper-item>
                        <view class="swiper-item">
                            <image class="swiper-img" src="/static/img/b3.jpg" mode=""></image>
                        </view>
                    </swiper-item>
                </swiper>
            </view>
        </template>
    
        <script>
        </script>
    
        <style lang="scss">
    
        /* 清楚swiper默认高度 */
        swiper{
            width: 750rpx;
            height: 450rpx;
        }
        .swiper-img{
            width: 100%;
        }
        </style>
    
  • 在index.vue中使用组件:
    使用组件分两步先引用在注册
        <template>
            <view class="content">
                <view class="index">
                    <IndexSwiper></IndexSwiper>
                </view>
                <view class="f-active-color">
                    文字
                </view>
                <view class="iconfont icon-xiaoxi"></view>
                <view class="text-area">
                    <text class="title">{{title}}</text>
                </view>
            </view>
        </template>
    
        <script>
            import IndexSwiper from '@/components/indexSwiper.vue';//引入
            export default {
                data() {
                    return {
                        title: 'Hello'
                    }
                },
                components:{
                    IndexSwiper //注册
                    
                },
                onLoad() {
    
                },
                methods: {
    
                }
            }
        </script>
    
    

img
Swiper部分 预览图

相关文章:

  • Spring启动源码分析以及生命周期
  • 斜率优化dp
  • 前端开发常用网站整理
  • 直流有刷电机电流采集基于STM32F302R8+X-NUCLEO-IHM07M1
  • 27_GitGitHub
  • 微信公众号在线查题功能系统使用
  • WPS JS宏示例-批量添加链接
  • Java核心——面向对象编程(上)包-继承-多态
  • Ambari自动部署Hadoop集群实战
  • 33.0、C语言——C语言预处理(1) - 翻译环境详解
  • java-php-python-springboot网上订餐系统计算机毕业设计
  • 【VUE项目实战】66、上线-通过node创建Web服务器
  • About 9.25 This Week
  • 三、基本命令
  • MySQL中select ... for update会锁表还是锁行?
  • ES学习笔记(12)--Symbol
  • Eureka 2.0 开源流产,真的对你影响很大吗?
  • Facebook AccountKit 接入的坑点
  • Logstash 参考指南(目录)
  • Mysql5.6主从复制
  • PHP 7 修改了什么呢 -- 2
  • Python 使用 Tornado 框架实现 WebHook 自动部署 Git 项目
  • Python利用正则抓取网页内容保存到本地
  • React的组件模式
  • SAP云平台运行环境Cloud Foundry和Neo的区别
  • Spring Boot快速入门(一):Hello Spring Boot
  • Spring Cloud中负载均衡器概览
  • thinkphp5.1 easywechat4 微信第三方开放平台
  • Vue UI框架库开发介绍
  • XForms - 更强大的Form
  • zookeeper系列(七)实战分布式命名服务
  • 从PHP迁移至Golang - 基础篇
  • 猴子数据域名防封接口降低小说被封的风险
  • 解决iview多表头动态更改列元素发生的错误
  • 聊聊spring cloud的LoadBalancerAutoConfiguration
  • 前端设计模式
  • 数据结构java版之冒泡排序及优化
  • 大数据全解:定义、价值及挑战
  • 容器镜像
  • ​Linux·i2c驱动架构​
  • ​secrets --- 生成管理密码的安全随机数​
  • # Java NIO(一)FileChannel
  • # Swust 12th acm 邀请赛# [ A ] A+B problem [题解]
  • #QT(TCP网络编程-服务端)
  • $GOPATH/go.mod exists but should not goland
  • (02)vite环境变量配置
  • (2)(2.10) LTM telemetry
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (介绍与使用)物联网NodeMCUESP8266(ESP-12F)连接新版onenet mqtt协议实现上传数据(温湿度)和下发指令(控制LED灯)
  • (论文阅读22/100)Learning a Deep Compact Image Representation for Visual Tracking
  • (四)docker:为mysql和java jar运行环境创建同一网络,容器互联
  • (四)Linux Shell编程——输入输出重定向
  • (转)EXC_BREAKPOINT僵尸错误
  • (转)大型网站的系统架构
  • (轉貼)《OOD启思录》:61条面向对象设计的经验原则 (OO)