The whole process record of introducing Vant framework into WeChat applet

The whole process record of introducing Vant framework into WeChat applet

Preface

Sometimes I feel that the native UI of WeChat mini-programs is a little bit lacking, so can we introduce a third-party framework? This article takes the introduction of Vant as an example, which includes 8 steps in total. It is used regardless of whether it is a cloud development project or not.

Implementation steps

1. Open the WeChat applet development tool and enter the project. Right click on the root folder of the project. Select Open in Terminal. (Note that it is the root directory)

2. Type npm init in the command window. Then all configurations are performed according to the default configuration, just click the Enter key.

3. Type npm install in the command window to build. If successful, package.json and package-lock.json files will be generated in the root directory.

4. Next, continue to install the Vant framework. The steps can be followed according to the official website vant-contrib.gitee.io/vant-weapp/…

4.1 npm i @vant/weapp -S --production

4.2 npm i vant-weapp -S --production

4.3 Modify app.json

4.4 Modify project.config.json

5. Return to WeChat Developer Tools and find "Build npm" in the "Tools" column. Wait for the build to succeed.

6. Finally, we need to use the npm module. In "Details", find "Use npm module" and check it.

7. Use Vant components and introduce them in app.json or index.json. For details, see Vant official website Quick Start

8. To use it in the page, just import the component directly.

··· Interlude···

Since this is a project built with a test AppId, I did not use cloud development. As a result, an error message is reported after the subsequent steps are completed! The error message is as shown in the figure below (1). It was then that I realized that the project directory was different from the file directory of another cloud-developed project of mine, which resulted in the file not being found. I don’t know the specific reason. But I was successful in the cloud development project, as shown in Figure (2) below; the steps are exactly the same as those written above.

From this we can conclude that everyone should try to use the official AppId (that is, the AppId after successful registration in the Mini Program public platform). Avoid getting into more trouble later.

I originally wanted to use the cloud development project to operate it again and put up the final successful results instead of recording a problematic note. But after thinking about it, this is not a bad idea. It reminds myself not to make this mistake again next time. So finally I present this blog to you all. I hope this can also serve as a reminder for everyone to pay attention to details and not be careless.

··· A magical scene···

The next day I opened the WeChat developer tools and found that the project with the test number AppId was working again, and the console error message was gone. This is very embarrassing! I don’t really understand what’s going on (if anyone knows, please just give me the answer! I’m afraid to speak…). Directly on the picture, as shown below (3);

Figure (1): Error message

Figure (2): Cloud development project successfully using Vant components

Figure (3): Test number AppId successfully uses Vant framework

Summarize

This is the end of this article about introducing Vant framework into WeChat mini program. For more relevant content about introducing Vant framework into WeChat mini program, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Specific steps to use vant framework in WeChat applet

<<:  CentOS 7.2 builds nginx web server to deploy uniapp project

>>:  Detailed explanation of count without filter conditions in MySQL

Recommend

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

9 Tips for Web Page Layout

<br />Related articles: 9 practical suggesti...

Detailed process of FastAPI deployment on Docker

Docker Learning https://www.cnblogs.com/poloyy/p/...

How to implement remote access control in Centos 7.4

1. SSH remote management SSH is a secure channel ...

Detailed explanation of the relationship between Vue and VueComponent

The following case reviews the knowledge points o...

JavaScript example code to determine whether a file exists

1. Business Scenario I have been doing developmen...

Detailed explanation of how Angular handles unexpected exception errors

Written in front No matter how well the code is w...

CSS style writing order and naming conventions and precautions

The significance of writing order Reduce browser ...

CSS float property diagram float property details

Using the CSS float property correctly can become...

About the problem of dynamic splicing src image address of img in Vue

Let's take a look at the dynamic splicing of ...

Summary of Mysql high performance optimization skills

Database Command Specification All database objec...

Solution to large line spacing (5 pixels more in IE)

Copy code The code is as follows: li {width:300px...

js development plug-in to achieve tab effect

This article example shares the specific code of ...

Vue custom table column implementation process record

Table of contents Preface Rendering setTable comp...

MySQL Server 8.0.13.0 Installation Tutorial with Pictures and Text

Install 8.0.13 based on MySQL 6.1.3. MySQL 8.0.13...