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

uni-app小程序使用vant

步骤一:安装 Vant Weapp

# 通过 npm 安装
npm i @vant/weapp -S --production# 通过 yarn 安装
yarn add @vant/weapp --production# 安装 0.x 版本
npm i vant-weapp -S --production

步骤二:在根目录下创建“wxcomponents”文件夹

步骤三:找到依赖node_modules/@vant/weapp/dist,复制dist文件

在这里插入图片描述

步骤四:把刚刚复制的dist文件粘贴到刚刚新建的“wxcomponents”文件下同时将dist改名为vant

在这里插入图片描述

步骤五:在“pages.json”/“globalStyle”里配置“usingComponents”

"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "uni-app","navigationBarBackgroundColor": "#F8F8F8","backgroundColor": "#F8F8F8","usingComponents": {"van-action-sheet": "/wxcomponents/vant/action-sheet/index","van-area": "/wxcomponents/vant/area/index","van-button": "/wxcomponents/vant/button/index","van-card": "/wxcomponents/vant/card/index","van-cell": "/wxcomponents/vant/cell/index","van-cell-group": "/wxcomponents/vant/cell-group/index","van-checkbox": "/wxcomponents/vant/checkbox/index","van-checkbox-group": "/wxcomponents/vant/checkbox-group/index","van-col": "/wxcomponents/vant/col/index","van-dialog": "/wxcomponents/vant/dialog/index","van-field": "/wxcomponents/vant/field/index","van-goods-action": "/wxcomponents/vant/goods-action/index","van-goods-action-icon": "/wxcomponents/vant/goods-action-icon/index","van-goods-action-button": "/wxcomponents/vant/goods-action-button/index","van-icon": "/wxcomponents/vant/icon/index","van-loading": "/wxcomponents/vant/loading/index","van-nav-bar": "/wxcomponents/vant/nav-bar/index","van-notice-bar": "/wxcomponents/vant/notice-bar/index","van-notify": "/wxcomponents/vant/notify/index","van-panel": "/wxcomponents/vant/panel/index","van-popup": "/wxcomponents/vant/popup/index","van-progress": "/wxcomponents/vant/progress/index","van-radio": "/wxcomponents/vant/radio/index","van-radio-group": "/wxcomponents/vant/radio-group/index","van-row": "/wxcomponents/vant/row/index","van-search": "/wxcomponents/vant/search/index","van-slider": "/wxcomponents/vant/slider/index","van-stepper": "/wxcomponents/vant/stepper/index","van-steps": "/wxcomponents/vant/steps/index","van-submit-bar": "/wxcomponents/vant/submit-bar/index","van-swipe-cell": "/wxcomponents/vant/swipe-cell/index","van-switch": "/wxcomponents/vant/switch/index","van-tab": "/wxcomponents/vant/tab/index","van-tabs": "/wxcomponents/vant/tabs/index","van-tabbar": "/wxcomponents/vant/tabbar/index","van-tabbar-item": "/wxcomponents/vant/tabbar-item/index","van-tag": "/wxcomponents/vant/tag/index","van-toast": "/wxcomponents/vant/toast/index","van-transition": "/wxcomponents/vant/transition/index","van-tree-select": "/wxcomponents/vant/tree-select/index","van-datetime-picker": "/wxcomponents/vant/datetime-picker/index","van-rate": "/wxcomponents/vant/rate/index","van-collapse": "/wxcomponents/vant/collapse/index","van-collapse-item": "/wxcomponents/vant/collapse-item/index","van-picker": "/wxcomponents/vant/picker/index","van-empty": "/wxcomponents/vant/empty/index"}},

步骤六:使用

<van-button type="default">默认按钮</van-button>
<van-button type="primary">主要按钮</van-button>
<van-button type="info">信息按钮</van-button>
<van-button type="warning">警告按钮</van-button>
<van-button type="danger">危险按钮</van-button>

end~~~

如有错误或观点不一致的请评论留言共同讨论,本人前端小白一枚,根据自己实际项目遇到的问题进行总结分享,谢谢大家的阅读!

相关文章:

  • 虚拟机VirtualBox添加磁盘
  • React——简便获取经纬度信息
  • 家庭私人影院 - Windows搭建Emby媒体库服务器并远程访问 「无公网IP」
  • 不必安装,快速设计数据库表结构
  • 【gpt redis】原理篇
  • 蓝桥杯官网填空题(含2天数)
  • Java程序设计2023-第三次上机练习
  • pytorch复现_conv2d
  • 读程序员的制胜技笔记04_有用的反模式(下)
  • 【重磅】Cookies、headers、Session规律总结,搞定卡点
  • 2023.11.4 Idea 配置国内 Maven 源
  • 高级深入--day46
  • 第一章 03Java入门-编写第一个Java程序HelloWorld以及JVM、JDK和JRE概念
  • promise最初理解
  • 系统提示缺少或找不到emp.dll文件的详细解决方案
  • 【407天】跃迁之路——程序员高效学习方法论探索系列(实验阶段164-2018.03.19)...
  • Apache Spark Streaming 使用实例
  • Docker容器管理
  • JAVA SE 6 GC调优笔记
  • JSDuck 与 AngularJS 融合技巧
  • Js基础——数据类型之Null和Undefined
  • leetcode-27. Remove Element
  • mysql常用命令汇总
  • React-Native - 收藏集 - 掘金
  • Sublime Text 2/3 绑定Eclipse快捷键
  • vue-router 实现分析
  • vue的全局变量和全局拦截请求器
  • XForms - 更强大的Form
  • 不用申请服务号就可以开发微信支付/支付宝/QQ钱包支付!附:直接可用的代码+demo...
  • 基于 Ueditor 的现代化编辑器 Neditor 1.5.4 发布
  • 七牛云假注销小指南
  • 前端
  • 如何优雅的使用vue+Dcloud(Hbuild)开发混合app
  • 设计模式走一遍---观察者模式
  • 通过调用文摘列表API获取文摘
  • ​力扣解法汇总1802. 有界数组中指定下标处的最大值
  • #Linux(Source Insight安装及工程建立)
  • #Z2294. 打印树的直径
  • #我与Java虚拟机的故事#连载02:“小蓝”陪伴的日日夜夜
  • ( )的作用是将计算机中的信息传送给用户,计算机应用基础 吉大15春学期《计算机应用基础》在线作业二及答案...
  • (9)目标检测_SSD的原理
  • (七)理解angular中的module和injector,即依赖注入
  • (四)Linux Shell编程——输入输出重定向
  • **登录+JWT+异常处理+拦截器+ThreadLocal-开发思想与代码实现**
  • .NET Core IdentityServer4实战-开篇介绍与规划
  • .Net Core与存储过程(一)
  • .NET 设计模式—适配器模式(Adapter Pattern)
  • .net 写了一个支持重试、熔断和超时策略的 HttpClient 实例池
  • .net 桌面开发 运行一阵子就自动关闭_聊城旋转门家用价格大约是多少,全自动旋转门,期待合作...
  • .NET6实现破解Modbus poll点表配置文件
  • .NET开发不可不知、不可不用的辅助类(三)(报表导出---终结版)
  • .NET与java的MVC模式(2):struts2核心工作流程与原理
  • /usr/bin/perl:bad interpreter:No such file or directory 的解决办法
  • @Autowired标签与 @Resource标签 的区别
  • @Conditional注解详解