• 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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    步骤二:在根目录下创建“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"
    		}
    	},
    
    • 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

    步骤六:使用

    <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>
    
    • 1
    • 2
    • 3
    • 4
    • 5

    end~~~

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

  • 相关阅读:
    MySQL之分库分表
    LeNet-5学习笔记
    1.11 LaTex插入图片
    关于XML 编辑工具
    Servlet urlPatterns配置
    代码随想录算法训练营第五十一天 |309.最佳买卖股票时机含冷冻期、714.买卖股票的最佳时机含手续费、总结
    docker swarm下部署的spring cloud,时不时就会取到ingress网络的ip
    移动硬盘删除的文件如何恢复呢?
    嵌入式培训机构四个月实训课程笔记(完整版)-Linux ARM驱动编程第七天-内核函数接口(物联技术666)
    flink集群与资源@k8s源码分析-资源III 声明式资源管理
  • 原文地址:https://blog.csdn.net/LingHuzh/article/details/134182077