uniapp项目中引入vant-Weapp(局部全局都有 史上最详细的方法)

2023-10-29 23:59

本文主要是介绍uniapp项目中引入vant-Weapp(局部全局都有 史上最详细的方法),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.先在根目录创建wxcomponents文件夹

2.打开 https://github.com/youzan/vant-weapp 下载最新的vant-Weapp

 3.把我们下好的文件vant-weapp里面只留下dist其余的可以全部删掉,然后把vant-weapp放到 wxcomponents里面

4.在App.vue引入vant样式

@import '/wxcomponents/vant-weapp/dist/common/index.wxss'

5.然后在pages.json引入(局部引入)

"usingComponents": {
                  "van-button": "/wxcomponents/vant-weapp/dist/button/index"
                }

6. 然后在页面引入button(注意:你在当前页面引入了button其他的页面没有引入,其他页面就用不了,其他页面想用,就得在path相应的路径引入)

 7.这个时候页面会报错,注意:(重新启动项目即可)

 8.然后就可以看到页面的组件出来了

 9.下面是全局引入

 10.分享一些常用的组件你们直接复制到你的usingComponents下面页面就可以直接用了

"usingComponents": {//这里为方便,全局引入了所有组件,也可以在某个page下单独引用某个组件"van-action-sheet": "/wxcomponents/vant-weapp/dist/action-sheet/index","van-area": "/wxcomponents/vant-weapp/dist/area/index",// "van-badge": "/wxcomponents/vant-weapp/dist/badge/index",// "van-badge-group": "/wxcomponents/vant-weapp/dist/badge-group/index","van-button": "/wxcomponents/vant-weapp/dist/button/index","van-card": "/wxcomponents/vant-weapp/dist/card/index","van-cell": "/wxcomponents/vant-weapp/dist/cell/index","van-cell-group": "/wxcomponents/vant-weapp/dist/cell-group/index","van-checkbox": "/wxcomponents/vant-weapp/dist/checkbox/index","van-checkbox-group": "/wxcomponents/vant-weapp/dist/checkbox-group/index","van-col": "/wxcomponents/vant-weapp/dist/col/index","van-dialog": "/wxcomponents/vant-weapp/dist/dialog/index","van-field": "/wxcomponents/vant-weapp/dist/field/index","van-goods-action": "/wxcomponents/vant-weapp/dist/goods-action/index","van-goods-action-icon": "/wxcomponents/vant-weapp/dist/goods-action-icon/index","van-goods-action-button": "/wxcomponents/vant-weapp/dist/goods-action-button/index","van-icon": "/wxcomponents/vant-weapp/dist/icon/index","van-loading": "/wxcomponents/vant-weapp/dist/loading/index","van-nav-bar": "/wxcomponents/vant-weapp/dist/nav-bar/index","van-notice-bar": "/wxcomponents/vant-weapp/dist/notice-bar/index","van-notify": "/wxcomponents/vant-weapp/dist/notify/index","van-panel": "/wxcomponents/vant-weapp/dist/panel/index","van-popup": "/wxcomponents/vant-weapp/dist/popup/index","van-progress": "/wxcomponents/vant-weapp/dist/progress/index","van-radio": "/wxcomponents/vant-weapp/dist/radio/index","van-radio-group": "/wxcomponents/vant-weapp/dist/radio-group/index","van-row": "/wxcomponents/vant-weapp/dist/row/index","van-search": "/wxcomponents/vant-weapp/dist/search/index","van-slider": "/wxcomponents/vant-weapp/dist/slider/index","van-stepper": "/wxcomponents/vant-weapp/dist/stepper/index","van-steps": "/wxcomponents/vant-weapp/dist/steps/index","van-submit-bar": "/wxcomponents/vant-weapp/dist/submit-bar/index","van-swipe-cell": "/wxcomponents/vant-weapp/dist/swipe-cell/index","van-switch": "/wxcomponents/vant-weapp/dist/switch/index",// "van-switch-cell": "/wxcomponents/vant-weapp/dist/switch-cell/index","van-tab": "/wxcomponents/vant-weapp/dist/tab/index","van-tabs": "/wxcomponents/vant-weapp/dist/tabs/index","van-tabbar": "/wxcomponents/vant-weapp/dist/tabbar/index","van-tabbar-item": "/wxcomponents/vant-weapp/dist/tabbar-item/index","van-tag": "/wxcomponents/vant-weapp/dist/tag/index","van-toast": "/wxcomponents/vant-weapp/dist/toast/index","van-transition": "/wxcomponents/vant-weapp/dist/transition/index","van-tree-select": "/wxcomponents/vant-weapp/dist/tree-select/index","van-datetime-picker": "/wxcomponents/vant-weapp/dist/datetime-picker/index","van-rate": "/wxcomponents/vant-weapp/dist/rate/index","van-collapse": "/wxcomponents/vant-weapp/dist/collapse/index","van-collapse-item": "/wxcomponents/vant-weapp/dist/collapse-item/index","van-picker": "/wxcomponents/vant-weapp/dist/picker/index"}

以上就是局部全局的方法啦,记得点个赞

这篇关于uniapp项目中引入vant-Weapp(局部全局都有 史上最详细的方法)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/304262

相关文章

SpringBoot中使用Flux实现流式返回的方法小结

《SpringBoot中使用Flux实现流式返回的方法小结》文章介绍流式返回(StreamingResponse)在SpringBoot中通过Flux实现,优势包括提升用户体验、降低内存消耗、支持长连... 目录背景流式返回的核心概念与优势1. 提升用户体验2. 降低内存消耗3. 支持长连接与实时通信在Sp

Conda虚拟环境的复制和迁移的四种方法实现

《Conda虚拟环境的复制和迁移的四种方法实现》本文主要介绍了Conda虚拟环境的复制和迁移的四种方法实现,包括requirements.txt,environment.yml,conda-pack,... 目录在本机复制Conda虚拟环境相同操作系统之间复制环境方法一:requirements.txt方法

Nginx 重写与重定向配置方法

《Nginx重写与重定向配置方法》Nginx重写与重定向区别:重写修改路径(客户端无感知),重定向跳转新URL(客户端感知),try_files检查文件/目录存在性,return301直接返回永久重... 目录一.try_files指令二.return指令三.rewrite指令区分重写与重定向重写: 请求

MySQL 打开binlog日志的方法及注意事项

《MySQL打开binlog日志的方法及注意事项》本文给大家介绍MySQL打开binlog日志的方法及注意事项,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录一、默认状态二、如何检查 binlog 状态三、如何开启 binlog3.1 临时开启(重启后失效)

Python中提取文件名扩展名的多种方法实现

《Python中提取文件名扩展名的多种方法实现》在Python编程中,经常会遇到需要从文件名中提取扩展名的场景,Python提供了多种方法来实现这一功能,不同方法适用于不同的场景和需求,包括os.pa... 目录技术背景实现步骤方法一:使用os.path.splitext方法二:使用pathlib模块方法三

Python打印对象所有属性和值的方法小结

《Python打印对象所有属性和值的方法小结》在Python开发过程中,调试代码时经常需要查看对象的当前状态,也就是对象的所有属性和对应的值,然而,Python并没有像PHP的print_r那样直接提... 目录python中打印对象所有属性和值的方法实现步骤1. 使用vars()和pprint()2. 使

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求

CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比

《CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比》CSS中的position属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布... css 中的 position 属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布局和层叠关

springboot项目中整合高德地图的实践

《springboot项目中整合高德地图的实践》:本文主要介绍springboot项目中整合高德地图的实践,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一:高德开放平台的使用二:创建数据库(我是用的是mysql)三:Springboot所需的依赖(根据你的需求再

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4