赞
踩
LiuJInTao:2024年4月6日
步骤一 通过 npm 安装
使用npm构建前,请先阅读微信官方的npm支持
>
通过 npm 安装
npm i @vant/weapp -S --production
通过 yarn 安装
yarn add @vant/weapp --production
安装 0.x 版本
npm i vant-weapp -S --production
步骤二 修改app.json
将 app.json 中的"style": "v2"强大,小程序的新版组件基础强行加上了许多样式,难以覆盖,不关闭将造成部分组件样式混乱。
最主要的就是查阅官方文档进行使用
》 看看css变量是如何定义和使用的:
使用方式和css变量是一样的, 使用 – 开头,在使用的时候使用 var函数传入自定义css变量的变量名即可。
注意:下面带中的 html 指明的是该css变量的作用域,不同的作用域,则属性名字也不一样。
关于颜色的名字,可以参考官方文档复制使用即可。
一、
二、
// 该文件夹专门用来创建 store 实例对象的。 import { observable, action } from 'mobx-miniprogram' export const sotre = observable ({ num1: 1, num2: 2, // 计算属性 get sum () { return this.num1 + this.num2 }, // 创建修改数据方法 updateNum1: action(function (step) { this.num1 += step }), updateNum2: action(function(step) { this.num2 += step }) })
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 取出 store 映射过来的数据 this.storeBindings = createStoreBindings(this, { // 数据源 store, // 映射的属性 fields: ['num1', 'num2', 'sum'], // 映射的方法 actions: ['updateSum1'] }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { // 清除数据 this.storeBindings.destroyStoreBindings() },
添加代码: "custom": true,
注意:组件内使用组件库后,想要修改样式是无法直接覆盖修改的,需要我们进行配置
"list": [ { "pagePath": "pages/home/home", "text": "首页", "iconPath": "/images/tabs/home.png", "selectedIconPath": "/images/tabs/home-active.png" }, { "pagePath": "pages/message/message", "text": "消息", "iconPath": "/images/tabs/message.png", "selectedIconPath": "/images/tabs/message-active.png" }, { "pagePath": "pages/contact/contact", "text": "联系我们", "iconPath": "/images/tabs/contact.png", "selectedIconPath": "/images/tabs/contact-active.png" } ]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。