当前位置:网站首页>微信小程序中使用vant组件
微信小程序中使用vant组件
2022-06-24 19:03:00 【suoh's Blog】
安装步骤:
步骤一: 通过npm安装指定版本vant
1、在项目空白处右键,有个在外部终端窗口打开,点击
出现以下窗口
2、在安装包的时候,需要保证项目里面有package.json文件。所以需要初始化一个包管理文件。
npm init -y
3、安装指定版本vant
> npm i @vant/[email protected] -S --production
步骤二: 构建npm包
1、打开微信开发者工具,点击工具>>构建npm,构建完成后,即可引入组件
2、点击上图的确定之后,还需要点击右上角的详情,选择本地设置,勾选 使用npm模块
我的是新版本 没有这一项 就不需要手动勾选了。
步骤三:修改app.json
《注意》去除该文件中的 style:'v2',小程序的新版基础组件强行加上了许多样式,难以去除,不关闭的话将造成部分组件样式混乱。
此时就安装vant成功了~
步骤四:如何使用
安装完vant组件库之后,可以在app.json的usingComponents节点中引入需要的组件,即可在wxml中直接使用组件。
(1)按需引入:
在对应的page页面的 .json文件中的usingComponents属性中通过路径找到@vant引入你想使用的组件。我的vant是位于下面目录中。
引入:
(2)全局引入
在app.json文件中引入。缺点就是会给项目启动造成压力,最好还是按需引入。
边栏推荐
- 史上最全DPU厂商大盘点(上)
- It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
- 天天鉴宝暴雷背后:拖欠数千万、APP停摆,创始人预谋跑路?
- "Super point" in "Meng Hua Lu", is the goose wronged?
- Teach you how to cancel computer hibernation
- RF_DC系统时钟设置GEN1/GEN2
- Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
- 建立自己的网站(14)
- Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
- Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1
猜你喜欢
顺序表的基本操作
顺序栈遍历二叉树
物聯網?快來看 Arduino 上雲啦
天天鉴宝暴雷背后:拖欠数千万、APP停摆,创始人预谋跑路?
"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"
Teach you how to cancel computer hibernation
Two solutions to the problem of 0xv0000225 unable to start the computer
Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
The four stages of cloud computing development have finally been clarified
Otaku can't save yuan universe
随机推荐
unity实战之lol技能释放范围
16个优秀业务流程管理工具
使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
Five day summary of software testing
Database index can improve query efficiency. Ask what will improve, what is the difference between inapplicable index and index use, and what will happen.
Fundamentals of performance testing -- definitions of common terms
Comparative analysis of arrayblockingqueue and linkedblockingqueue
Two solutions to the problem of 0xv0000225 unable to start the computer
Material management system based on SSM (source code + document + database)
Ribbon source code analysis @loadbalanced and loadbalancerclient
Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
[suggested collection] time series prediction application and paper summary
Docker installing Oracle
Hosting service and SASE, enjoy the integration of network and security | phase I review
对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿
京东一面:Redis 如何实现库存扣减操作?如何防止商品被超卖?
Using dynamic time warping (DTW) to solve the similarity measurement of time series and the similarity identification analysis of pollution concentration in upstream and downstream rivers
Install the custom module into the system and use find in the independent project_ Package found
What is CNN (convolutional neural network)
Byte and Tencent have also come to an end. How fragrant is this business of "making 30million yuan a month"?