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

Mini Program Custom TabBar Component Encapsulation

This article example shares the specific code for...

Summary of Linux file basic attributes knowledge points

The Linux system is a typical multi-user system. ...

How to switch directories efficiently in Linux

When it comes to switching directories under Linu...

Vue uses WebSocket to simulate the chat function

The effect shows that two browsers simulate each ...

HTML fixed title column, title header table specific implementation code

Copy code The code is as follows: <!DOCTYPE ht...

19 MySQL optimization methods in database management

After MySQL database optimization, not only can t...

How to keep running after exiting Docker container

Phenomenon: Run an image, for example, ubuntu14.0...

Detailed explanation of the lock structure in MySQL

Mysql supports 3 types of lock structures Table-l...

Beginners learn some HTML tags (1)

Beginners can learn HTML by understanding some HT...

Quick understanding and example application of Vuex state machine

Table of contents 1. Quick understanding of conce...

Web front-end development course What are the web front-end development tools

With the development of Internet technology, user...

Get a list of your top 10 most frequently used terminal commands in Linux

I think the commands I use most often are: Choice...

vue $set implements assignment of values ​​to array collection objects

Vue $set array collection object assignment In th...