vue vant ui 教程注意事项

2024-04-26 22:58

本文主要是介绍vue vant ui 教程注意事项,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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;
}

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>

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;}}}}

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

04

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

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

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

/deep/.channel-tabs {.van-tab {border-right: 1px solid #edeff3;}}

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

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

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

图片

这篇关于vue vant ui 教程注意事项的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/938893

相关文章

Vue3使用router,params传参为空问题

《Vue3使用router,params传参为空问题》:本文主要介绍Vue3使用router,params传参为空问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录vue3使用China编程router,params传参为空1.使用query方式传参2.使用 Histo

Python 安装和配置flask, flask_cors的图文教程

《Python安装和配置flask,flask_cors的图文教程》:本文主要介绍Python安装和配置flask,flask_cors的图文教程,本文通过图文并茂的形式给大家介绍的非常详细,... 目录一.python安装:二,配置环境变量,三:检查Python安装和环境变量,四:安装flask和flas

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

CSS Padding 和 Margin 区别全解析

《CSSPadding和Margin区别全解析》CSS中的padding和margin是两个非常基础且重要的属性,它们用于控制元素周围的空白区域,本文将详细介绍padding和... 目录css Padding 和 Margin 全解析1. Padding: 内边距2. Margin: 外边距3. Padd

CSS will-change 属性示例详解

《CSSwill-change属性示例详解》will-change是一个CSS属性,用于告诉浏览器某个元素在未来可能会发生哪些变化,本文给大家介绍CSSwill-change属性详解,感... will-change 是一个 css 属性,用于告诉浏览器某个元素在未来可能会发生哪些变化。这可以帮助浏览器优化

CSS去除a标签的下划线的几种方法

《CSS去除a标签的下划线的几种方法》本文给大家分享在CSS中,去除a标签(超链接)的下划线的几种方法,本文给大家介绍的非常详细,感兴趣的朋友一起看看吧... 在 css 中,去除a标签(超链接)的下划线主要有以下几种方法:使用text-decoration属性通用选择器设置:使用a标签选择器,将tex

Ubuntu中远程连接Mysql数据库的详细图文教程

《Ubuntu中远程连接Mysql数据库的详细图文教程》Ubuntu是一个以桌面应用为主的Linux发行版操作系统,这篇文章主要为大家详细介绍了Ubuntu中远程连接Mysql数据库的详细图文教程,有... 目录1、版本2、检查有没有mysql2.1 查询是否安装了Mysql包2.2 查看Mysql版本2.

前端高级CSS用法示例详解

《前端高级CSS用法示例详解》在前端开发中,CSS(层叠样式表)不仅是用来控制网页的外观和布局,更是实现复杂交互和动态效果的关键技术之一,随着前端技术的不断发展,CSS的用法也日益丰富和高级,本文将深... 前端高级css用法在前端开发中,CSS(层叠样式表)不仅是用来控制网页的外观和布局,更是实现复杂交

Python将博客内容html导出为Markdown格式

《Python将博客内容html导出为Markdown格式》Python将博客内容html导出为Markdown格式,通过博客url地址抓取文章,分析并提取出文章标题和内容,将内容构建成html,再转... 目录一、为什么要搞?二、准备如何搞?三、说搞咱就搞!抓取文章提取内容构建html转存markdown

在React中引入Tailwind CSS的完整指南

《在React中引入TailwindCSS的完整指南》在现代前端开发中,使用UI库可以显著提高开发效率,TailwindCSS是一个功能类优先的CSS框架,本文将详细介绍如何在Reac... 目录前言一、Tailwind css 简介二、创建 React 项目使用 Create React App 创建项目