Small program -----vant weapp installation and custom theme color

First check whether there is a package.json file in the root directory of the applet

If not, open cmd in the project root directory, enter npm init -yinitialization, and initialize a package management

Install the vant weapp package

Enter in the cmd of the root directory npm i @vant/[email protected] -S --productionto install @ and you can specify the version

Modify app.json

Remove "style": "v2" from app.json, and the new version of the applet's basic components forcefully add many styles, which are difficult to overwrite. If they are not closed, the styles of some components will be confused.

build npm

insert image description here

custom theme color

Custom theme color
https://github.com/youzan/vant-weapp/blob/dev/packages/common/style/var.less
insert image description here

Define the color under the page in the applet app.wxss

page {
    
    
  --button-default-color: #ff0000;
}

Use vanbutton normally in the page

<van-button type="default">默认按钮</van-button>

You can see that the theme color has been changed

insert image description here

Guess you like

Origin blog.csdn.net/zyue_1217/article/details/131731772