当前位置:   article > 正文

vue vant ui 教程&注意事项_van-image image-class

van-image image-class

Hi,很高兴认识你~

世界很大,巧妙的是我们在这里相遇。

欢迎关注天宇文创意乐派,一个职场人的聚集地。

官网:https://youzan.github.io/vant/#/zh-CN/

01

vant 插件PullRefresh下拉刷新 会出现滚动就刷新的情况

常见问题:

1.父级容器不存在overflow:hidden

2.当使用Refresh插件时,如果存在当van-refresh组件的父级overfow-y:scorll 的样式时,选中的滚动条为父级元素,此时当body内部容器撑开页面元素时(也就是body存在滚动条时)

解决方式:

1.给父级容器加上overflow:hidden

2.设置van-refresh组件的父级组件的正确高度,使body的高度不会出现滚动条。

.van-pull-refresh {
     height: 100vh;
     overflow: auto !important;
}
  • 1
  • 2
  • 3
  • 4

PullRefresh 的内容未填满屏幕时,只有一部分区域可以下拉?默认情况下,下拉区域的高度是和内容高度保持一致的,如果需要让下拉区域始终为全屏,可以给 PullRefresh 设置一个与屏幕大小相等的最小高度:

vant ui 官网

02

vant  van-icon使用自定义图标

iconfont图标库: https://www.iconfont.cn/

图片

搜索自己喜好的图标 添加入库

图片

点击我的图标库  选择对应的项目  点击确定

图片

点击更新代码

图片

复制css代码到 Vue项目中

图片

引入到项目中的位置 切记打包时 要配置http或https的形式

图片

可以在App.vue 或main.js  我这里是配置在main.js中

图片

vue文件中的使用

<template>
  <div id="tabbar">
    <!-- 给tabbar route属性  然后给每一项to属性就可以路由跳转了 -->
    <van-tabbar  route>
      <van-tabbar-item icon="home-o" to="/">书架</van-tabbar-item>
      <van-tabbar-item to="/bookShop" >
        <div class="customTabbarItem">
          <!--引入自定义图标-->
          <van-icon class="iconfont iconicon_huabanfuben icon_margin"/>
          <span>书城</span>
        </div>
      </van-tabbar-item>
      <van-tabbar-item to="/bookClass" >
        <div class="customTabbarItem">
          <!--引入自定义图标-->
          <van-icon class="iconfont iconleimupinleifenleileibie icon_margin"/>
          <span>分类</span>
        </div>
      </van-tabbar-item>
      <van-tabbar-item icon="user-o" to="/profile">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

03

vant swiper 轮播图圆角滑动变会变成直角然后再回到圆角(iOS)

#template部分
<van-pull-refresh v-model="isLoading" @refresh="init" :disabled="open" :style="{backgroundColor: bgColor}" class="pull-container">
            <!-- 轮播图 -->
            <div class="cu-swipe" v-if="bannerList.length>0" >
                <van-swipe :autoplay="3000">
                    <van-swipe-item v-for="(banner, index) in bannerList" :key="index" @click="toJump(banner)">
                        <!-- 轮播图去掉 lazy-load 属性  -->
                        <van-image :src="STATIC_HOST + banner.imageLink"/>
                    </van-swipe-item>
                </van-swipe>
            </div>
            <div class="book-list-container">
                <!-- 主编推荐 -->
                <div class="book-recommend-wrapper">
                    <div class="recommend-header">
                        <div class="recommend-header-left"><h1>主编推荐</h1></div>
                        <div class="recommend-header-right">
                            <div class="recommend-icon-item">
                                <van-icon name="star" class="icon_margin" />
                                <span>品质</span>
                            </div>
                            <div class="recommend-icon-item">
                                <van-icon name="star" class="icon_margin"/>
                                <span>人气</span>
                            </div>
                            <div class="recommend-icon-item last">
                                <van-icon name="star" class="icon_margin"/>
                                <span>兴趣</span>
                            </div>
                        </div>
                    </div>
                    <van-row type="flex" justify="space-between" v-if="recommendList.length>0">
                        <van-col span="7" v-for="(recommend, index) in recommendList">
                            <router-link :key="recommend.id" :to="{path: '/bookDetail', query:{bookId: recommend.id}}">
                                <van-image class="recommend-cover" lazy-load :src="STATIC_HOST + recommend.coverImg" />
                                <span class="recommend-title">{{recommend.title}}</span>
                            </router-link>
                        </van-col>
                    </van-row>
                </div>
                <!-- 高分神作  -->
                <div class="book-eight-wrapper">
                    <van-row class="book-eight-wrapper-header">
                        <van-col span="24" class="header-left"><h1>高分神作</h1></van-col>
                    </van-row>
                    <van-row type="flex" justify="space-between" v-for="(i) in 2">
                        <van-col span="5" v-for="(highScore, index) in highScoreList" v-if=" i===1 && index < 4 ">
                            <router-link :key="highScore.id" :to="{path: '/bookDetail', query:{bookId: highScore.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + highScore.coverImg" />
                                <span class="book-eight-wrapper-title">{{highScore.title}}</span>
                                <span class="book-eight-wrapper-score">9.7<span class="unit">分</span></span>
                            </router-link>
                        </van-col>
                        <van-col span="5" v-for="(highScore, index) in highScoreList" v-if=" i===2 && index >= 4">
                            <router-link :key="highScore.id" :to="{path: '/bookDetail', query:{bookId: highScore.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + highScore.coverImg" />
                                <span class="book-eight-wrapper-title">{{highScore.title}}</span>
                                <span class="book-eight-wrapper-score">9.7<span class="unit">分</span></span>
                            </router-link>
                        </van-col>
                    </van-row>
                </div>
                <!--潜力新书-->
                <div class="book-eight-wrapper">
                    <div class="book-eight-wrapper-header">
                        <div class="header-left"><h1>潜力新书</h1></div>
                        <div class="header-right">
                            <a @click="handleMore('潜力新书','SERIAL')">
                                <span>更多</span>
                                <span><van-icon class="iconfont icongengduo"/></span>
                            </a>
                        </div>
                    </div>
                    <van-row type="flex" justify="space-between" v-for="(i) in 2">
                        <van-col span="5" v-for="(item, index) in newVos" v-if=" i===1 && index < 4 ">
                            <router-link :key="item.id" :to="{path: '/bookDetail', query:{bookId: item.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + item.coverImg" />
                                <span class="book-eight-wrapper-title">{{item.title}}</span>
                                <span class="book-eight-wrapper-label">{{processLabelInfo(item.labelInfo)}}</span>
                            </router-link>
                        </van-col>
                        <van-col span="5" v-for="(item, index) in newVos" v-if=" i===2 && index >= 4">
                            <router-link :key="item.id" :to="{path: '/bookDetail', query:{bookId: item.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + item.coverImg" />
                                <span class="book-eight-wrapper-title">{{item.title}}</span>
                                <span class="book-eight-wrapper-label">{{processLabelInfo(item.labelInfo)}}</span>
                            </router-link>
                        </van-col>
                    </van-row>
                </div>
                <!--完结优选-->
                <div class="book-eight-wrapper">
                    <div class="book-eight-wrapper-header">
                        <div class="header-left"><h1>完结优选</h1></div>
                        <div class="header-right">
                            <a @click="handleMore('爆款完本','FINISH')">
                                <span>更多</span>
                                <span><van-icon class="iconfont icongengduo"/></span>
                            </a>
                        </div>
                    </div>
                    <van-row type="flex" justify="space-between" v-for="(i) in 2">
                        <van-col span="5" v-for="(item, index) in finishVos" v-if=" i===1 && index < 4 ">
                            <router-link :key="item.id" :to="{path: '/bookDetail', query:{bookId: item.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + item.coverImg" />
                                <span class="book-eight-wrapper-title">{{item.title}}</span>
                                <span class="book-eight-wrapper-label">{{processLabelInfo(item.labelInfo)}}</span>
                            </router-link>
                        </van-col>
                        <van-col span="5" v-for="(item, index) in finishVos" v-if=" i===2 && index >= 4">
                            <router-link :key="item.id" :to="{path: '/bookDetail', query:{bookId: item.id}}">
                                <van-image class="book-eight-wrapper-cover" lazy-load :src="STATIC_HOST + item.coverImg" />
                                <span class="book-eight-wrapper-title">{{item.title}}</span>
                                <span class="book-eight-wrapper-label">{{processLabelInfo(item.labelInfo)}}</span>
                            </router-link>
                        </van-col>
                    </van-row>
                </div>
            </div>
        </van-pull-refresh>
#css部分
.pull-container {
        position: relative;
        min-height: 100vh;
        width: 100%;
        overflow-y: auto; //解决IOS 动态变化时 先变直角在变圆角的处理方案
        border: none;
        .van-hairline--bottom:after {
            border-bottom-width: 0;
        }
        .cu-swipe{
            margin: 0.533rem 0.533rem 0 0.533rem; //可以单独改变元素的上,右,下,左边距,也可以一次改变所有的属性。
            -webkit-border-radius: 0.267rem 0.267rem 0 0;
            -moz-border-radius: 0.267rem 0.267rem 0 0;
            overflow-y: auto; //解决IOS 动态变化时 先变直角在变圆角的处理方案
            .van-swipe-item {
                width: 100%;
                height: 4rem;
                font-size: 0.533rem;
                text-align: center;
                transform: translateY(0); //解决IOS 动态变化时 先变直角在变圆角的处理方案
                img{
                    display:block;
                    vertical-align:top;
                    width: 100%;
                    height: 4rem;
                }
            }
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150

由于页面内容太多 我只粘贴主要部分不用直接上来就复制粘贴

04

vue  vant ui  vant-tab 标签页组件样式调整

<van-tabs
v-model="active"
sticky
title-active-color="#144a9e" // 选中的标签文字颜色
color="#144a9e" // 下面那个下划线颜色
@click="tabClick">
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

改变van-tab边框颜色 在类名前加上深度操作符: /deep/

/deep/.channel-tabs {
      .van-tab {
        border-right: 1px solid #edeff3;
      }
    }
  • 1
  • 2
  • 3
  • 4
  • 5

改变van-tab 标签:宽高 文字颜色大小, 底部条:宽高 颜色 位置

.van-tabs__nav {  //父元素默认底边15px 可以去掉
  padding-bottom: 0;
}
.van-tabs__line {
  bottom: 8px;
  width: 31px !important;
  height: 6px;
        background-color: #3296fa;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

目前暂时遇到以上的一些必写的  后续遇到在补充

图片

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/92353
推荐阅读
  • 1问题描述今天来分享一个违背Java跨平台的问题,在学习Java第一课老师肯定就是吹嘘Java如何强大,如何跨平台,如何一次编译,到处执行;本文就遇见了在本地windows环境开发没有问题,在Linux的服务器上运行各种异常,这不是有点违背... [详细]

  • 小白都会的Docker的基本命令_dockerrunimagedockerrunimage介绍本文docker命令操作是在linxu系统下,所以我们先从linux安装docker开始。1、docker在linux系统下安装相关命令1.1安... [详细]

  • 1.什么是compose?为什么要使用compose?因为运行一个docker镜像,通常是需要dockerrun命令,在运行镜像的时候还需要一定的参数;例如容器的名称映射的卷,绑定端口等等,非常麻烦。那如果有个一个文件来记录保存这些命令该多... [详细]

  • 1、安装docker-compose官网https://docs.docker.com/compose/一个不错的入门网站https://docker_practice.gitee.io/compose/compose_file.html重... [详细]

  • 论文理解-VGGNet-VeryDeepConvolutionalNetworksforLarge-ScaleImageRecognition[VGG-Paper][原文地址-Verydeepconvolutionalnetworksfor... [详细]

  • 数据结构与算法(10):排序相关本次内容主要是LeetCodesorttags下的题目的解法和思路,基础排序方法并没有在此记录,但可能会直接用在相关题目,以下是记录,题号与LeetCode对应。题目1:922.SortArrayByPari... [详细]

  • Docker是一个开源项目,为开发者和系统管理员提供了一个开放的平台,在任何地方通过打包和运行应用程序作为一个轻量级的容器。Docker在软件容器内自动部署应用程序。Docker最开始由SolomonHykes作为dotCloud一个内部开... [详细]

  • 初学Vue在应用界面中,某个(些)元素的样式是变化的,class/style绑定就是专门用来实现动态样式效果的技术。1、绑定class样式基本语法::class="xxx"表达式是字符串:“classA”表达式是对象时:{classA:is... [详细]

  • glanceimage-create--name"linux-core-mini-01"--file/cirros-0.3.4-x86_64-disk.img--disk-formatqcow2--container-formatbare-... [详细]

  • openstackglance上传镜像glanceopenstack中提供镜像服务的子项目,本文主要介绍glance上传镜像的过程。glance服务包含glance-api和glance-registry两个服务。glance-api负责... [详细]

  • 文章目录1.Abstract说明:本文是对原版论文和一位大神解读的基础上,加以自己的理解而作,如有错误,欢迎指正。大神的文章链接1.Abstract'对于深度学习模型来说,当用在一个新的问题上,就需要对可变设置人为设定。对新问题的适应包括精... [详细]

  • nnU-Net:基于U-Net的自适应医学图像分割框架基于U-Net提出了nnU-Net框架,可以自动调整模型的体系结构以适应不同数据集。作者认为现有的模型在结构方面的调整可能会导致模型在某一些特定的数据集上过拟合,同时非架构的部分在图像分... [详细]

  • nnU-Net是基于U-Net的医学图像分割的自适应框架,对不同任务的网络结构、预处理、训练和推断进行了优化。文章讨论了网络结构调整的实际价值和进化式的改进。nnu-net:self-adaptingframeworkforu-net-ba... [详细]

  • 本篇主要解读论文“nnU-Net:Self-adaptingFrameworkforU-Net-BasedMedicalImageSegmentation”==nnU-Net:基于U-Net的自适应医学图像分割框架。实现见本专栏下其他博文。... [详细]

  • U-net在图像分割中是一个很有用的模型。针对不同的问题,U-net在模型架构、预处理、训练和推导上均有一定的自由度。这些部分对于模型整体表现起到很重要的作用。这篇论文提出了nnU-net(no-newU-net),这是一个2D&3D经典U... [详细]

  • javascript中的class构造函数一、函数存在变量提升,但是类不存在变量提升二、函数受函数作用域限制,但是类受块级作用域限制