赞
踩
- 1、 yarn init 或 npm init
-
- 2、 # 通过 npm 安装
- npm i @vant/weapp -S --production
-
- # 通过 yarn 安装
- yarn add @vant/weapp --production
-
- # 安装 0.x 版本
- npm i vant-weapp -S --production
- <style lang="scss">
- /*每个页面公共css */
- /* #ifdef MP-WEIXIN */
- @import "/wxcomponents/dist/common/index.wxss"; //路径要确保正确!!!!
- /* #endif */
- </style>
- "globalStyle": {
- "navigationBarTextStyle": "black",
- "navigationBarTitleText": "uni-app",
- "navigationBarBackgroundColor": "#F8F8F8",
- "backgroundColor": "#F8F8F8",
- "usingComponents": {
- "van-button": "/wxcomponents/dist/button/index",
- "van-circle": "/wxcomponents/dist/circle/index"
- }
- },
运行结果:
代码:
- <template>
- <view class="content">
- <van-button type="default">默认按钮</van-button>
- <van-button type="primary">主要按钮</van-button>
- <van-button type="info">信息按钮</van-button>
- <van-button type="warning">警告按钮</van-button>
- <van-button type="danger">危险按钮</van-button>
- <view style="margin-top: 30rpx;">
- <van-circle :value="value" :color="gradientColor" text="渐变色" />
- </view>
- </view>
- </template>
-
- <script>
- export default {
- data() {
- return {
- value: 0, //进度
- gradientColor: { //渐变色
- '0%': '#ffd01e',
- '50%': '#aa55ff',
- '100%': '#ee0a24',
- },
- item: null,
- }
- },
- onUnload() {
- clearInterval(this.item)
- this.item = null
- },
- onLoad() {
- this.item = setInterval(() => {
- if (this.value >= 100) {
- this.value = 0
- return
- } else {
- this.value += 10
- }
- }, 1000)
- },
- methods: {
-
- }
- }
- </script>
-
- <style>
- .content {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- </style>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。