当前位置:网站首页>微信小程序中使用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文件中引入。缺点就是会给项目启动造成压力,最好还是按需引入。
边栏推荐
- RF_DC系统时钟设置GEN1/GEN2
- Oracle create tablespaces and tables
- Introduction: continuously update the self-study version of the learning manual for junior test development engineers
- 16个优秀业务流程管理工具
- To open the registry
- What is CNN (convolutional neural network)
- Unit actual combat lol skill release range
- SQL export CSV data, unlimited number of entries
- Install the custom module into the system and use find in the independent project_ Package found
- Hutool reads large excel (over 10m) files
猜你喜欢

When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
The name of the button in the Siyuan notes toolbar has changed to undefined. Has anyone ever encountered it?

Apache+php+mysql environment construction is super detailed!!!

Q1: error in JMeter filename must not be null or empty

Implement the redis simple client customized based on socket

Error in Android connection database query statement

Redis installation of CentOS system under Linux, adding, querying, deleting, and querying all keys

"Super point" in "Meng Hua Lu", is the goose wronged?

Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?

Why is the executor thread pool framework introduced
随机推荐
Coinbase将推出首个针对个人投资者的加密衍生产品
Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month
Comparative analysis of arrayblockingqueue and linkedblockingqueue
2022年最新四川建筑八大员(电气施工员)模拟题库及答案
Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
Apache+php+mysql environment construction is super detailed!!!
[suggested collection] time series prediction application and paper summary
[go language questions] go from 0 to entry 4: advanced usage of slice, elementary review and introduction to map
Five day summary of software testing
OpenVINO2022 Dev Tools安装与使用
对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿
C langage pour le déminage (version simplifiée)
Jd.com: how does redis implement inventory deduction? How to prevent oversold?
年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
消息称腾讯正式宣布成立“XR”部门,押注元宇宙;谷歌前 CEO:美国即将输掉芯片竞争,要让台积电、三星建更多工厂...
unity实战之lol技能释放范围
16个优秀业务流程管理工具
Introduction: continuously update the self-study version of the learning manual for junior test development engineers
Bytebase joins Alibaba cloud polardb open source database community
RF_DC系统时钟设置GEN1/GEN2