diff --git a/assets/iframe-router.8a0fc162.js b/assets/iframe-router.8a0fc162.js deleted file mode 100644 index de0df2581..000000000 --- a/assets/iframe-router.8a0fc162.js +++ /dev/null @@ -1,3455 +0,0 @@ -import{o as e,a as p,u as d}from"./vue-libs.1ccdd11c.js";const b=function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))l(t);new MutationObserver(t=>{for(const c of t)if(c.type==="childList")for(const r of c.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&l(r)}).observe(document,{childList:!0,subtree:!0});function n(t){const c={};return t.integrity&&(c.integrity=t.integrity),t.referrerpolicy&&(c.referrerPolicy=t.referrerpolicy),t.crossorigin==="use-credentials"?c.credentials="include":t.crossorigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(t){if(t.ep)return;t.ep=!0;const c=n(t);fetch(t.href,c)}};b();var Un=(a,s)=>{const n=a.__vccOpts||a;for(const[l,t]of s)n[l]=t;return n};const v={class:"van-doc-markdown-body"},q=d('
2023-07-10
Bug Fixes
Feature
2023-07-03
Bug Fixes
Document
Feature
2023-05-19
Bug Fixes
2023-05-08
Bug Fixes
Feature
2023-05-04
Bug Fixes
2023-04-18
Bug Fixes
2023-04-03
Bug Fixes
Feature
hotfix
2023-02-27
Bug Fixes
Document
Feature
2023-02-13
Bug Fixes
Feature
2023-01-16
Bug Fixes
Document
Feature
2023-01-03
Bug Fixes
Feature
2022-12-16
Bug Fixes
Document
Feature
2022-12-12
Bug Fixes
Feature
2022-11-29
Bug Fixes
Document
Feature
2022-11-18
Bug Fixes
Document
Feature
2022-11-06
Bug Fixes
Feature
2022-09-07
Feature
Bug Fixes
2022-07-23
Feature
Bug Fixes
box-sizing: border-box
\u5BFC\u81F4\u5BFC\u822A\u680F\u9AD8\u5EA6\u4E0D\u6B63\u786E\u95EE\u9898 #49692022-05-02
Feature
Bug Fixes
2022-01-04
Bug Fixes
Document
Feature
2021-12-21
Bug Fixes
Document
Feature
2021-10-28
Bug Fixes
Feature
2021-09-29
Bug Fixes
Document
Feature
2021-09-27
Bug Fixes
Document
Feature
Performance
2021-09-07
Bug Fixes
Features
2021-08-30
Bug Fixes
Features
Performance Improvements
2021-08-18
Feature
Bug Fixes
2021-08-11
Feature
Performance
2021-07-19
Bug Fixes
Features
2021-07-04
Bug Fixes
weapp-qrcode
wechat-moments
#4256Features
Improvements
2021-05-22
Bug Fixes
Features
2021-02-26
Features
Bug Fixes
Improvements
2021-01-21
Features
Bug Fixes
Improvements
2021-01-19
Features
Bug Fixes
Improvements
2020-12-18
Improvements
Bug Fixes
max
min
\u65F6\u6ED1\u52A8\u4E0D\u5747\u5300 (#3876)2020-12-09
Features
beforeClose
\u5C5E\u6027 (#3815)county_list
\u6570\u636E (#3824)resize
\u65B9\u6CD5 (#3827)Improvements
Bug Fixes
percentage
\u4E3A 0 \u65F6\u6837\u5F0F\u5F02\u5E38 (#3808)2020-11-29
Features
placeholder
icon-prefix
\u5C5E\u6027 (#3792)Bug Fixes
type=year-month
\u65F6\u9009\u62E9\u51FA\u73B0\u62A5\u9519 (#3783)ellipsis
\u4E3A false
\u65F6\u4E0B\u5212\u7EBF\u4F4D\u7F6E\u4E0D\u6B63\u786E (#3777)Improvements
2020-11-11
Features
custom-class
#3678Bug Fixes
label
\u5C5E\u6027\u65F6 label-class
\u6837\u5F0F\u7C7B\u4E0D\u751F\u6548 #3729scrollable
\u4E0D\u751F\u6548 #37272020-10-15
Features
Bug Fixes
2020-09-29
Features
origin-price
tag
\u63D2\u69FD #3645Bug Fixes
2020-08-27
Features
Bug Fixes
2020-07-28
Features
Bug Fixes
2020-07-17
Features
Bug Fixes
2020-06-24
Features
Bug Fixes
2020-06-04
Features
Bug Fixes
square
\u65F6\u6A2A\u3001\u7EB5\u5411\u95F4\u8DDD\u4E0D\u540C #3231type="2d"
\u4E0D\u751F\u6548 #32282020-05-24
Features
Bug Fixes
2020-05-08
1.3.0 \u4E2D\uFF0C\u6211\u4EEC\u4E3A\u6570\u4E2A\u8868\u5355\u7EC4\u4EF6\u652F\u6301\u4E86\u7B80\u6613\u53CC\u5411\u7ED1\u5B9A\uFF0C\u6D89\u53CA\u7EC4\u4EF6\u6709
Slider #3107
Search #3106
Rate #3105
Features
Bug Fixes
2020-04-21
Features
Bug Fixes
2020-04-12
Features
Bug Fixes
2020-04-04
Features
Bug Fixes
2020-03-21
Features
Bug Fixes
2020-03-04
Features
popupStyle
\u5C5E\u6027 #2804open
close
opened
closed
\u4E8B\u4EF6 #2804price
num
\u63D2\u69FD #2787origin-price-class
\u5916\u90E8\u6837\u5F0F\u7C7B #2787Bug Fixes
name
\u7C7B\u578B\u4E0Evalue
\u7EDF\u4E00 #28012020-02-24
Features
Bug Fixes
close
\u4E8B\u4EF6 #2766disabled
\u5C5E\u6027\u65E0\u6548 #2748label-disabled
\u6587\u6863\u9519\u8BEF #27632020-02-07
Features
disabled
\u65F6\u7684\u7EC4\u4EF6\u6837\u5F0F #2720Bug Fixes
disabled
\u5C5E\u6027\u4E0D\u751F\u6548 #2711animated
\u5C5E\u6027\u65E0\u6CD5\u52A8\u6001\u5207\u6362 #2712size
\u5C5E\u6027\u4E0D\u652F\u6301string
\u7C7B\u578B #26942020-01-21
Features
Bug Fixes
2020-01-09
Features
Bug Fixes
2019-12-31
Features
row-class``avatar-class``title-class
#2612width
\u5C5E\u6027 #2607camera``compressed``maxDuration
\u5C5E\u6027 #2584Improvements
Bug Fixes
2019-12-23
Features
Improvements
Bug Fixes
2019-12-11
CSS\u81EA\u5B9A\u4E49\u5C5E\u6027
\u81EA\u5B9A\u4E49\u6837\u5F0Fenv()
\u91CD\u6784 iOS \u5B89\u5168\u533A\u57DF\u9002\u914D\u5728 Vant Weapp 1.0 \u7248\u672C\u4E2D\uFF0C\u6211\u4EEC\u65B0\u589E\u4E86 11 \u4E2A\u5B9E\u7528\u7684\u57FA\u7840\u7EC4\u4EF6\uFF1A
position: sticky
\u5C5E\u6027\u5B9E\u73B0\u7684\u6548\u679C\u7C7B\u4F3C\u5728 1.0 \u8FED\u4EE3\u8BA1\u5212\u786E\u5B9A\u4E4B\u521D\uFF0C\u6211\u4EEC\u5C31\u4E0D\u65AD\u601D\u8003\u8FD9\u6837\u4E00\u4E2A\u95EE\u9898 -- \u8BE5\u5982\u4F55\u7ED9\u7528\u6237\u63D0\u4F9B\u52A8\u6001\u5207\u6362\u4E3B\u9898\u6837\u5F0F\u7684\u529F\u80FD\u5462\uFF1F
\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684\u73AF\u5883\u662F\u975E\u5E38\u7279\u6B8A\u7684\u3002\u4E0D\u5177\u6709\u52A8\u6001\u52A0\u8F7D\u4EE3\u7801\u7684\u673A\u5236\uFF0C\u540C\u65F6\u5FAE\u4FE1\u53C8\u9650\u5236\u4E86\u4EE3\u7801\u7684\u4E3B\u5305\u5927\u5C0F\u548C\u603B\u5927\u5C0F\u3002\u4F20\u7EDF\u7684\u57FA\u4E8E\u9884\u8BBE\u7684\u6837\u5F0F\u5B9A\u5236\u8FC7\u4E8E\u81C3\u80BF\uFF0C\u4E0D\u518D\u9002\u5408\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684\u73AF\u5883\u3002
\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u7684\u7EC4\u4EF6\u6A21\u578B\u76F8\u5F53\u4E8E\u4E00\u4E2A\u7B80\u5316\u7248\u7684 Shadow DOM\uFF0C\u5E78\u8FD0\u7684\u662F\uFF0C\u5C0F\u7A0B\u5E8F\u4E5F\u652F\u6301\u4E86 CSS \u81EA\u5B9A\u4E49\u5C5E\u6027 \u7684\u7279\u6027\u3002\u6700\u7EC8\uFF0C\u6211\u4EEC\u57FA\u4E8E CSS \u81EA\u5B9A\u4E49\u5C5E\u6027\u8BBE\u8BA1\u4E86\u6837\u5F0F\u5B9A\u5236\u7684\u65B9\u6848\uFF0C\u5F00\u53D1\u8005\u4F7F\u7528\u7075\u6D3B\u3001\u65B9\u4FBF\uFF0C\u7EC4\u4EF6\u7EF4\u62A4\u4E5F\u66F4\u7B80\u5355\u3002
\u4ECE 1.0 \u7248\u672C\u5F00\u59CB\uFF0CVant Weapp \u4E2D\u7684\u6240\u6709\u7EC4\u4EF6\u90FD\u652F\u6301\u901A\u8FC7 CSS \u7EC4\u5B9A\u4E49\u5C5E\u6027 \u8FDB\u884C\u6837\u5F0F\u5B9A\u5236\uFF0C\u5177\u4F53\u4F7F\u7528\u59FF\u52BF\u53EF\u67E5\u770B\u76F8\u5173\u6587\u6863
1.0 \u7248\u672C\u4E2D\u5305\u542B\u5C11\u91CF\u4E0D\u517C\u5BB9\u66F4\u65B0\uFF0C\u4E3B\u8981\u662F\u547D\u540D\u8C03\u6574\u548C\u79FB\u9664\u4E2A\u522B\u5C5E\u6027\u3002\u5BF9\u4E8E\u6B63\u5728\u4F7F\u7528 0.x \u7248\u672C\u7684\u9879\u76EE\uFF0C\u8BF7\u6309\u7167\u4E0B\u65B9\u7684\u5217\u8868\u4F9D\u6B21\u68C0\u67E5\uFF0C\u5927\u90E8\u5206\u9879\u76EE\u53EF\u4EE5\u65E0\u75DB\u5347\u7EA7\u3002
BadgeGroup
\u91CD\u547D\u540D\u4E3ASidebar
Badge
\u91CD\u547D\u540D\u4E3ASlidebarItem
active
\u5C5E\u6027\u91CD\u547D\u540D\u4E3AactiveKey
text
\u9009\u9879\u91CD\u547D\u540D\u4E3Amessage
backgroundColor
\u9009\u9879\u91CD\u547D\u540D\u4E3Abackground
transitionend
\u4E8B\u4EF6\uFF0C\u65B0\u589E 6 \u4E2A\u4E8B\u4EF6SwitchCell
\u7EC4\u4EF6\uFF0C\u53EF\u4EE5\u4F7F\u7528Cell
\u548CSwitch
\u7EC4\u4EF6\u4EE3\u66FFtransitionend
\u4E8B\u4EF6\uFF0C\u65B0\u589E 6 \u4E2A\u4E8B\u4EF6click-overlay
\u4E8B\u4EF6close-on-click-action
\u5C5E\u6027color
\u5C5E\u6027description
\u5C5E\u6027round
\u5C5E\u6027columns-placeholder
\u5C5E\u6027reset
\u65B9\u6CD5\u652F\u6301\u4F20\u5165code
\u53C2\u6570loading-type
\u5C5E\u6027color
\u5C5E\u6027\u652F\u6301\u6E10\u53D8\u8272disabled
\u65F6\u589E\u52A0\u8FC7\u6E21\u6548\u679Cicon-size
\u5C5E\u6027#ee0a24
filter
\u5C5E\u6027title
\u63D2\u69FDconfirm-button-color
\u5C5E\u6027cancel-button-color
\u5C5E\u6027width
\u5C5E\u6027overlay-style
\u5C5E\u6027clickable
\u5C5E\u6027arrow-direction
\u5C5E\u6027hold-keyboard
\u5C5E\u6027color
\u5C5E\u6027icon
\u63D2\u69FDdot
\u5C5E\u6027info
\u5C5E\u6027dot
\u5C5E\u6027dot
\u5C5E\u6027down
\u56FE\u6807wap-hone
\u5B9E\u5E95\u98CE\u683C\u56FE\u6807number
\u7C7B\u578B\u7684size
\u5C5E\u6027number
\u7C7B\u578B\u7684size
\u5C5E\u6027clear
\u65B9\u6CD5round
\u5C5E\u6027closeable
\u5C5E\u6027close-icon
\u5C5E\u6027close-icon-position
\u5C5E\u6027stroke-width
\u5C5E\u6027icon-size
\u5C5E\u6027gutter
\u5C5E\u6027touchable
\u5C5E\u6027string
\u7C7B\u578B\u7684size
\u5C5E\u6027action-text
\u5C5E\u6027left-icon
\u63D2\u69FDright-icon
\u63D2\u69FDdot
\u5C5E\u6027drag-start
\u4E8B\u4EF6drag-end
\u4E8B\u4EF6max
\u548Cmin
\u5C5E\u6027number
\u7C7B\u578B\u7684bar-height
\u5C5E\u6027name
\u5C5E\u6027open
\u4E8B\u4EF6input-width
\u5C5E\u6027button-size
\u5C5E\u6027decimalLength
\u5C5E\u6027active-icon
\u5C5E\u6027inactive-icon
\u5C5E\u6027name
\u5C5E\u6027line-height
\u5C5E\u6027ellipsis
\u5C5E\u6027lazy-render
\u5C5E\u6027line-width
\u5C5E\u6027\u652F\u6301String
\u7C7B\u578Bmax
\u5C5E\u6027content
\u63D2\u69FDVant Weapp \u57FA\u4E8E\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684\u673A\u5236\uFF0C\u4E3A\u5F00\u53D1\u8005\u63D0\u4F9B\u4E86\u4EE5\u4E0B 3 \u79CD\u4FEE\u6539\u7EC4\u4EF6\u6837\u5F0F\u7684\u65B9\u6CD5
\u6837\u5F0F\u9694\u79BB\u7684\u76F8\u5173\u80CC\u666F\u77E5\u8BC6\u8BF7\u67E5\u9605\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6587\u6863
Vant Weapp \u7684\u6240\u6709\u7EC4\u4EF6\u90FD\u5F00\u542F\u4E86addGlobalClass: true
\u4EE5\u63A5\u53D7\u5916\u90E8\u6837\u5F0F\u7684\u5F71\u54CD\uFF0C\u53EF\u4EE5\u4F7F\u7528\u5982\u4E0B 2 \u79CD\u65B9\u5F0F\u8986\u76D6\u7EC4\u4EF6\u6837\u5F0F
\u5728\u9875\u9762\u4E2D\u4F7F\u7528 Vant Weapp \u7EC4\u4EF6\u65F6\uFF0C\u53EF\u76F4\u63A5\u5728\u9875\u9762\u7684\u6837\u5F0F\u6587\u4EF6\u4E2D\u8986\u76D6\u6837\u5F0F
<van-button type="primary">\u4E3B\u8981\u6309\u94AE</van-button>
-
/* page.wxss */
-.van-button--primary {
- font-size: 20px;
- background-color: pink;
-}
-
\u5728\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u4E2D\u4F7F\u7528 Vant Weapp \u7EC4\u4EF6\u65F6\uFF0C\u9700\u5F00\u542F
styleIsolation: 'shared'
\u9009\u9879
<van-button type="primary">\u4E3B\u8981\u6309\u94AE</van-button>
-
Component({
- options: {
- styleIsolation: 'shared',
- },
-});
-
.van-button--primary {
- font-size: 20px;
- background-color: pink;
-}
-
\u5916\u90E8\u6837\u5F0F\u7C7B\u7684\u76F8\u5173\u77E5\u8BC6\u80CC\u666F\u8BF7\u67E5\u9605\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6587\u6863
Vant Weapp \u5F00\u653E\u4E86\u5927\u91CF\u7684\u5916\u90E8\u6837\u5F0F\u7C7B\u4F9B\u5F00\u53D1\u8005\u4F7F\u7528\uFF0C\u5177\u4F53\u7684\u6837\u5F0F\u7C7B\u540D\u79F0\u53EF\u67E5\u9605\u5BF9\u5E94\u7EC4\u4EF6\u7684\u201C\u5916\u90E8\u6837\u5F0F\u7C7B\u201D\u90E8\u5206\u3002
\u9700\u8981\u6CE8\u610F\u7684\u662F\u666E\u901A\u6837\u5F0F\u7C7B\u548C\u5916\u90E8\u6837\u5F0F\u7C7B\u7684\u4F18\u5148\u7EA7\u662F\u672A\u5B9A\u4E49\u7684\uFF0C\u56E0\u6B64\u4F7F\u7528\u65F6\u8BF7\u6DFB\u52A0!important
\u4EE5\u4FDD\u8BC1\u5916\u90E8\u6837\u5F0F\u7C7B\u7684\u4F18\u5148\u7EA7\u3002
<van-cell
- title="\u5355\u5143\u683C"
- value="\u5185\u5BB9"
- title-class="cell-title"
- value-class="cell-value"
-/>
-
.cell-title {
- color: pink !important;
- font-size: 20px !important;
-}
-
-.cell-value {
- color: green !important;
- font-size: 12px !important;
-}
-
Vant Weapp \u4E3A\u90E8\u5206 CSS \u5C5E\u6027\u5F00\u653E\u4E86\u57FA\u4E8E CSS \u5C5E\u6027\u7684\u5B9A\u5236\u65B9\u6848\u3002
\u76F8\u8F83\u4E8E \u89E3\u9664\u6837\u5F0F\u9694\u79BB \u548C \u4F7F\u7528\u5916\u90E8\u6837\u5F0F\u7C7B\uFF0C\u8FD9\u79CD\u65B9\u6848\u652F\u6301\u5728\u9875\u9762\u6216\u5E94\u7528\u7EA7\u522B\u5BF9\u591A\u4E2A\u7EC4\u4EF6\u7684\u6837\u5F0F\u505A\u6279\u91CF\u4FEE\u6539\u4EE5\u8FDB\u884C\u4E3B\u9898\u6837\u5F0F\u7684\u5B9A\u5236\u3002
\u5F53\u7136\uFF0C\u7528\u5B83\u6765\u4FEE\u6539\u5355\u4E2A\u7EC4\u4EF6\u7684\u90E8\u5206\u6837\u5F0F\u4E5F\u662F\u7EF0\u7EF0\u6709\u4F59\u7684\u3002\u5177\u4F53\u7684\u4F7F\u7528\u65B9\u6CD5\u8BF7\u67E5\u9605\u5B9A\u5236\u4E3B\u9898
\u8F7B\u91CF\u3001\u53EF\u9760\u7684\u5C0F\u7A0B\u5E8F UI \u7EC4\u4EF6\u5E93
Vant \u662F\u4E00\u4E2A\u8F7B\u91CF\u3001\u53EF\u9760\u7684\u79FB\u52A8\u7AEF\u7EC4\u4EF6\u5E93\uFF0C\u4E8E 2017 \u5E74\u5F00\u6E90\u3002
\u76EE\u524D Vant \u5B98\u65B9\u63D0\u4F9B\u4E86 Vue 2 \u7248\u672C\u3001Vue 3 \u7248\u672C\u548C\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7248\u672C\uFF0C\u5E76\u7531\u793E\u533A\u56E2\u961F\u7EF4\u62A4 React \u7248\u672C\u548C\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u7248\u672C\u3002
\u626B\u63CF\u4E0B\u65B9\u5C0F\u7A0B\u5E8F\u4E8C\u7EF4\u7801\uFF0C\u4F53\u9A8C\u7EC4\u4EF6\u5E93\u793A\u4F8B\uFF1A
Tips: \u4E3A\u4E86\u4FBF\u4E8E\u9884\u89C8\u7EC4\u4EF6\u6548\u679C\uFF0C\u672C\u6587\u6863\u7684\u53F3\u4FA7\u5185\u5D4C\u4E86 H5 \u7248\u7684 Vant \u9875\u9762\u4F5C\u4E3A\u53C2\u8003\u3002\u5728\u5B9E\u9645\u4F7F\u7528\u4E2D\uFF0C\u4E2A\u522B\u7EC4\u4EF6\u7684\u8868\u73B0\u53EF\u80FD\u4E0E\u5C0F\u7A0B\u5E8F\u4E0A\u7684\u8868\u73B0\u6709\u5DEE\u5F02\uFF0C\u8BF7\u4EE5\u5B9E\u9645\u6548\u679C\u4E3A\u51C6\u3002
\u8BF7\u53C2\u8003 \u5FEB\u901F\u4E0A\u624B\u3002
\u4EE5\u4E0B\u662F Vant \u548C Vant Weapp \u7684\u6838\u5FC3\u8D21\u732E\u8005\u4EEC\uFF1A
chenjiahan | cookfront | wangnaiyi | pangxie | rex-zsd | nemo-shen |
Lindysen | JakeLaoyu | landluck | wjw-gavin | inottn | zhousg |
\u611F\u8C22\u4EE5\u4E0B\u5C0F\u4F19\u4F34\u4EEC\u4E3A Vant Weapp \u53D1\u5C55\u505A\u51FA\u7684\u8D21\u732E\uFF1A
\u4F7F\u7528\u8FC7\u7A0B\u4E2D\u53D1\u73B0\u4EFB\u4F55\u95EE\u9898\u90FD\u53EF\u4EE5\u63D0 Issue \u7ED9\u6211\u4EEC\uFF0C\u5F53\u7136\uFF0C\u6211\u4EEC\u4E5F\u975E\u5E38\u6B22\u8FCE\u4F60\u7ED9\u6211\u4EEC\u53D1 PR\u3002
\u672C\u9879\u76EE\u57FA\u4E8E MIT \u534F\u8BAE\uFF0C\u8BF7\u81EA\u7531\u5730\u4EAB\u53D7\u548C\u53C2\u4E0E\u5F00\u6E90\u3002
\u4F7F\u7528 Vant Weapp \u524D\uFF0C\u8BF7\u786E\u4FDD\u4F60\u5DF2\u7ECF\u5B66\u4E60\u8FC7\u5FAE\u4FE1\u5B98\u65B9\u7684 \u5C0F\u7A0B\u5E8F\u7B80\u6613\u6559\u7A0B \u548C \u81EA\u5B9A\u4E49\u7EC4\u4EF6\u4ECB\u7ECD\u3002
\u4F7F\u7528 npm \u6784\u5EFA\u524D\uFF0C\u8BF7\u5148\u9605\u8BFB\u5FAE\u4FE1\u5B98\u65B9\u7684 npm \u652F\u6301
# \u901A\u8FC7 npm \u5B89\u88C5
-npm i @vant/weapp -S --production
-
-# \u901A\u8FC7 yarn \u5B89\u88C5
-yarn add @vant/weapp --production
-
-# \u5B89\u88C5 0.x \u7248\u672C
-npm i vant-weapp -S --production
-
\u5C06 app.json \u4E2D\u7684 "style": "v2"
\u53BB\u9664\uFF0C\u5C0F\u7A0B\u5E8F\u7684\u65B0\u7248\u57FA\u7840\u7EC4\u4EF6\u5F3A\u884C\u52A0\u4E0A\u4E86\u8BB8\u591A\u6837\u5F0F\uFF0C\u96BE\u4EE5\u8986\u76D6\uFF0C\u4E0D\u5173\u95ED\u5C06\u9020\u6210\u90E8\u5206\u7EC4\u4EF6\u6837\u5F0F\u6DF7\u4E71\u3002
\u5F00\u53D1\u8005\u5DE5\u5177\u521B\u5EFA\u7684\u9879\u76EE\uFF0CminiprogramRoot
\u9ED8\u8BA4\u4E3A miniprogram
\uFF0Cpackage.json
\u5728\u5176\u5916\u90E8\uFF0Cnpm \u6784\u5EFA\u65E0\u6CD5\u6B63\u5E38\u5DE5\u4F5C\u3002
\u9700\u8981\u624B\u52A8\u5728 project.config.json
\u5185\u6DFB\u52A0\u5982\u4E0B\u914D\u7F6E\uFF0C\u4F7F\u5F00\u53D1\u8005\u5DE5\u5177\u53EF\u4EE5\u6B63\u786E\u7D22\u5F15\u5230 npm \u4F9D\u8D56\u7684\u4F4D\u7F6E\u3002
{
- ...
- "setting": {
- ...
- "packNpmManually": true,
- "packNpmRelationList": [
- {
- "packageJsonPath": "./package.json",
- "miniprogramNpmDistDir": "./miniprogram/"
- }
- ]
- }
-}
-
\u6CE8\u610F\uFF1A \u7531\u4E8E\u76EE\u524D\u65B0\u7248\u5F00\u53D1\u8005\u5DE5\u5177\u521B\u5EFA\u7684\u5C0F\u7A0B\u5E8F\u76EE\u5F55\u6587\u4EF6\u7ED3\u6784\u95EE\u9898\uFF0Cnpm\u6784\u5EFA\u7684\u6587\u4EF6\u76EE\u5F55\u4E3Aminiprogram_npm\uFF0C\u5E76\u4E14\u5F00\u53D1\u5DE5\u5177\u4F1A\u9ED8\u8BA4\u5728\u5F53\u524D\u76EE\u5F55\u4E0B\u521B\u5EFAminiprogram_npm\u7684\u6587\u4EF6\u540D\uFF0C\u6240\u4EE5\u65B0\u7248\u672C\u7684miniprogramNpmDistDir\u914D\u7F6E\u4E3A'./'\u5373\u53EF
\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u70B9\u51FB \u5DE5\u5177 -> \u6784\u5EFA npm\uFF0C\u5E76\u52FE\u9009 \u4F7F\u7528 npm \u6A21\u5757 \u9009\u9879\uFF0C\u6784\u5EFA\u5B8C\u6210\u540E\uFF0C\u5373\u53EF\u5F15\u5165\u7EC4\u4EF6\u3002
\u5982\u679C\u4F60\u4F7F\u7528 typescript \u5F00\u53D1\u5C0F\u7A0B\u5E8F\uFF0C\u8FD8\u9700\u8981\u505A\u5982\u4E0B\u64CD\u4F5C\uFF0C\u4EE5\u83B7\u5F97\u987A\u7545\u7684\u5F00\u53D1\u4F53\u9A8C\u3002
# \u901A\u8FC7 npm \u5B89\u88C5
-npm i -D miniprogram-api-typings
-
-# \u901A\u8FC7 yarn \u5B89\u88C5
-yarn add -D miniprogram-api-typings
-
\u8BF7\u5C06path/to/node_modules/@vant/weapp
\u4FEE\u6539\u4E3A\u9879\u76EE\u7684 node_modules
\u4E2D @vant/weapp \u6240\u5728\u7684\u76EE\u5F55\u3002
{
- ...
- "compilerOptions": {
- ...
- "baseUrl": ".",
- "types": ["miniprogram-api-typings"],
- "paths": {
- "@vant/weapp/*": ["path/to/node_modules/@vant/weapp/dist/*"]
- },
- "lib": ["ES6"]
- }
-}
-
\u6211\u4EEC\u63D0\u4F9B\u4E86\u4E00\u4E2A\u793A\u4F8B\u5DE5\u7A0B\uFF0C\u793A\u4F8B\u5DE5\u7A0B\u4F1A\u5E2E\u52A9\u4F60\u4E86\u89E3\u5982\u4E0B\u5185\u5BB9\uFF1A
\u4EE5 Button \u7EC4\u4EF6\u4E3A\u4F8B\uFF0C\u53EA\u9700\u8981\u5728app.json
\u6216index.json
\u4E2D\u914D\u7F6E Button \u5BF9\u5E94\u7684\u8DEF\u5F84\u5373\u53EF\u3002
\u6240\u6709\u7EC4\u4EF6\u6587\u6863\u4E2D\u7684\u5F15\u5165\u8DEF\u5F84\u5747\u4EE5 npm \u5B89\u88C5\u4E3A\u4F8B\uFF0C\u5982\u679C\u4F60\u662F\u901A\u8FC7\u4E0B\u8F7D\u6E90\u4EE3\u7801\u7684\u65B9\u5F0F\u4F7F\u7528 @vant/weapp\uFF0C\u8BF7\u5C06\u8DEF\u5F84\u4FEE\u6539\u4E3A\u9879\u76EE\u4E2D @vant/weapp \u6240\u5728\u7684\u76EE\u5F55\u3002
// \u901A\u8FC7 npm \u5B89\u88C5
-// app.json
-"usingComponents": {
- "van-button": "@vant/weapp/button/index"
-}
-
// \u901A\u8FC7\u4E0B\u8F7D\u6E90\u7801\u4F7F\u7528 es6\u7248\u672C
-// app.json
-"usingComponents": {
- "van-button": "path/to/@vant/weapp/dist/button/index"
-}
-
// \u901A\u8FC7\u4E0B\u8F7D\u6E90\u7801\u4F7F\u7528 es5\u7248\u672C
-// app.json
-"usingComponents": {
- "van-button": "path/to/@vant/weapp/lib/button/index"
-}
-
\u5F15\u5165\u7EC4\u4EF6\u540E\uFF0C\u53EF\u4EE5\u5728 wxml \u4E2D\u76F4\u63A5\u4F7F\u7528\u7EC4\u4EF6
<van-button type="primary">\u6309\u94AE</van-button>
-
-# \u5C06\u9879\u76EE\u514B\u9686\u5230\u672C\u5730
-git clone git@github.com:youzan/vant-weapp.git
-
-# \u5B89\u88C5\u9879\u76EE\u4F9D\u8D56
-cd vant-weapp && npm install
-
-# \u6267\u884C\u7EC4\u4EF6\u7F16\u8BD1
-npm run dev
-
-
\u63A5\u7740\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165example
\u76EE\u5F55\u7684\u9879\u76EE\u5C31\u53EF\u4EE5\u9884\u89C8\u793A\u4F8B\u4E86\u3002
@vant/weapp \u90E8\u5206\u7EC4\u4EF6\u4F7F\u7528\u4E86\u5FAE\u4FE1\u63D0\u4F9B\u7684\u63A5\u53E3\uFF0C\u5176\u4E2D\u90E8\u5206\u63A5\u53E3\u6D89\u53CA\u83B7\u53D6\u7528\u6237\u9690\u79C1\u4FE1\u606F\u3002
\u4F8B\u5982 <Uploader />
\u4F7F\u7528\u4E86\u5FAE\u4FE1\u63D0\u4F9B\u7684\u9009\u62E9\u7528\u6237\u76F8\u518C\u4E2D\u56FE\u7247\u63A5\u53E3(wx.chooseImage)
\u3002
\u5F53\u5C0F\u7A0B\u5E8F\u5F15\u5165 @vant/weapp \u5E76\u53D1\u5E03\u65F6\uFF0C \u6839\u636E\u5FAE\u4FE1\u300A\u7528\u6237\u9690\u79C1\u4FDD\u62A4\u6307\u5F15\u586B\u5199\u8BF4\u660E\u300B\uFF0C \u5982\u68C0\u6D4B\u5230\u4EE3\u7801\u4E2D\u5B58\u5728\u6D89\u53CA\u7528\u6237\u9690\u79C1\u4FE1\u606F\u63A5\u53E3\u5219\u9700\u586B\u5199\u7528\u6237\u9690\u79C1\u4FDD\u62A4\u6307\u5F15\u4FE1\u606F\uFF0C\u5982\u5DF2\u586B\u5199\u5219\u65E0\u9700\u91CD\u590D\u586B\u5199\u3002
\u5C0F\u7A0B\u5E8F\u57FA\u4E8E Shadow DOM \u6765\u5B9E\u73B0\u81EA\u5B9A\u4E49\u7EC4\u4EF6\uFF0C\u6240\u4EE5 Vant Weapp \u4F7F\u7528\u4E0E\u4E4B\u914D\u5957\u7684 CSS \u53D8\u91CF \u6765\u5B9E\u73B0\u5B9A\u5236\u4E3B\u9898\u3002\u94FE\u63A5\u4E2D\u7684\u5185\u5BB9\u53EF\u4EE5\u5E2E\u52A9\u4F60\u5BF9\u8FD9\u4E24\u4E2A\u6982\u5FF5\u6709\u57FA\u672C\u7684\u8BA4\u8BC6\uFF0C\u907F\u514D\u8BB8\u591A\u4E0D\u5FC5\u8981\u7684\u56F0\u6270\u3002
CSS \u53D8\u91CF \u7684\u517C\u5BB9\u6027\u8981\u6C42\u53EF\u4EE5\u5728 \u8FD9\u91CC \u67E5\u770B\u3002\u5BF9\u4E8E\u4E0D\u652F\u6301 CSS \u53D8\u91CF \u7684\u8BBE\u5907\uFF0C\u5B9A\u5236\u4E3B\u9898\u5C06\u4E0D\u4F1A\u751F\u6548\uFF0C\u4E0D\u8FC7\u4E0D\u5FC5\u62C5\u5FC3\uFF0C\u9ED8\u8BA4\u6837\u5F0F\u4ECD\u4F1A\u751F\u6548\u3002
\u5B9A\u5236\u4F7F\u7528\u7684 CSS \u53D8\u91CF \u4E0E Less \u53D8\u91CF \u540C\u540D\uFF0C\u4E0B\u9762\u662F\u4E00\u4E9B\u57FA\u672C\u7684\u6837\u5F0F\u53D8\u91CF\uFF0C\u6240\u6709\u53EF\u7528\u7684\u989C\u8272\u53D8\u91CF\u8BF7\u53C2\u8003 \u914D\u7F6E\u6587\u4EF6\u3002
// Component Colors
-@text-color: #323233;
-@border-color: #ebedf0;
-@active-color: #f2f3f5;
-@background-color: #f8f8f8;
-@background-color-light: #fafafa;
-
\u5728 wxss \u4E2D\u4E3A\u7EC4\u4EF6\u8BBE\u7F6E CSS \u53D8\u91CF
<van-button class="my-button">
- \u9ED8\u8BA4\u6309\u94AE
-</van-button>
-
.my-button {
- --button-border-radius: 10px;
- --button-default-color: #f2f3f5;
-}
-
\u6216\u901A\u8FC7 style \u5C5E\u6027\u6765\u8BBE\u7F6E CSS \u53D8\u91CF\uFF0C\u8FD9\u4F7F\u4F60\u80FD\u591F\u8F7B\u677E\u5B9E\u73B0\u4E3B\u9898\u7684\u52A8\u6001\u5207\u6362
<van-button style="{{ buttonStyle }}">
- \u9ED8\u8BA4\u6309\u94AE
-</van-button>
-
Page({
- data: {
- buttonStyle: \`
- --button-border-radius: 10px;
- --button-default-color: green;
- \`,
- },
-
- onLoad() {
- setTimeout(() => {
- this.setData({
- buttonStyle: \`
- --button-border-radius: 2px;
- --button-default-color: pink;
- \`,
- });
- }, 2000);
- },
-});
-
\u4E0E\u5355\u4E2A\u7EC4\u4EF6\u7684\u5B9A\u5236\u65B9\u5F0F\u7C7B\u4F3C\uFF0C\u53EA\u9700\u7528\u4E00\u4E2A container \u8282\u70B9\u5305\u88F9\u4F4F\u9700\u8981\u5B9A\u5236\u7684\u7EC4\u4EF6\uFF0C\u5E76\u5C06 CSS \u53D8\u91CF \u8BBE\u7F6E\u5728 container \u8282\u70B9\u4E0A
<view class="container">
- <van-button bind:click="onClick">
- \u9ED8\u8BA4\u6309\u94AE
- </van-button>
-
- <van-toast id="van-toast" />
-</view>
-
import Toast from '@vant/weapp/toast/toast';
-
-Page({
- onClick() {
- Toast('\u6211\u662F\u63D0\u793A\u6587\u6848\uFF0C\u5EFA\u8BAE\u4E0D\u8D85\u8FC7\u5341\u4E94\u5B57~');
- },
-});
-
.container {
- --button-border-radius: 10px;
- --button-default-color: #f2f3f5;
- --toast-max-width: 100px;
- --toast-background-color: pink;
-}
-
\u5728 app.wxss \u4E2D\uFF0C\u5199\u5165 CSS \u53D8\u91CF\uFF0C\u5373\u53EF\u5BF9\u5168\u5C40\u751F\u6548
page {
- --button-border-radius: 10px;
- --button-default-color: #f2f3f5;
- --toast-max-width: 100px;
- --toast-background-color: pink;
-}
-
\u5E95\u90E8\u5F39\u8D77\u7684\u6A21\u6001\u9762\u677F\uFF0C\u5305\u542B\u4E0E\u5F53\u524D\u60C5\u5883\u76F8\u5173\u7684\u591A\u4E2A\u9009\u9879\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-action-sheet": "@vant/weapp/action-sheet/index"
-}
-
\u9700\u8981\u4F20\u5165\u4E00\u4E2Aactions
\u7684\u6570\u7EC4\uFF0C\u6570\u7EC4\u7684\u6BCF\u4E00\u9879\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF0C\u5BF9\u8C61\u5C5E\u6027\u89C1\u6587\u6863\u4E0B\u65B9\u8868\u683C\u3002
<van-action-sheet
- show="{{ show }}"
- actions="{{ actions }}"
- bind:close="onClose"
- bind:select="onSelect"
-/>
-
Page({
- data: {
- show: false,
- actions: [
- {
- name: '\u9009\u9879',
- },
- {
- name: '\u9009\u9879',
- },
- {
- name: '\u9009\u9879',
- subname: '\u63CF\u8FF0\u4FE1\u606F',
- openType: 'share',
- },
- ],
- },
-
- onClose() {
- this.setData({ show: false });
- },
-
- onSelect(event) {
- console.log(event.detail);
- },
-});
-
\u8BBE\u7F6Ecancel-text
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u5E95\u90E8\u5C55\u793A\u53D6\u6D88\u6309\u94AE\uFF0C\u70B9\u51FB\u540E\u5173\u95ED\u5F53\u524D\u83DC\u5355\u3002
<van-action-sheet
- show="{{ show }}"
- actions="{{ actions }}"
- cancel-text="\u53D6\u6D88"
-/>
-
\u8BBE\u7F6Edescription
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u9009\u9879\u4E0A\u65B9\u663E\u793A\u63CF\u8FF0\u4FE1\u606F\u3002
<van-action-sheet
- show="{{ show }}"
- actions="{{ actions }}"
- description="\u8FD9\u662F\u4E00\u6BB5\u63CF\u8FF0\u4FE1\u606F"
-/>
-
\u9009\u9879\u53EF\u4EE5\u8BBE\u7F6E\u4E3A\u52A0\u8F7D\u72B6\u6001\u6216\u7981\u7528\u72B6\u6001\u3002
<van-action-sheet
- show="{{ show }}"
- actions="{{ actions }}"
- cancel-text="\u53D6\u6D88"
-/>
-
Page({
- data: {
- show: false,
- actions: [
- { name: '\u7740\u8272\u9009\u9879', color: '#ee0a24' },
- { loading: true },
- { name: '\u7981\u7528\u9009\u9879', disabled: true },
- ],
- },
-});
-
\u901A\u8FC7\u8BBE\u7F6Etitle
\u5C5E\u6027\u5C55\u793A\u6807\u9898\u680F\uFF0C\u540C\u65F6\u53EF\u4EE5\u4F7F\u7528\u63D2\u69FD\u81EA\u5B9A\u4E49\u83DC\u5355\u5185\u5BB9\u3002
<van-action-sheet show="{{ show }}" title="\u6807\u9898">
- <view>\u5185\u5BB9</view>
-</van-action-sheet>
-
\u9700\u8981\u4F20\u5165\u4E00\u4E2Aactions
\u7684\u6570\u7EC4\uFF0C\u6570\u7EC4\u7684\u6BCF\u4E00\u9879\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF0C\u5BF9\u8C61\u5C5E\u6027\u89C1\u6587\u6863\u4E0B\u65B9\u8868\u683C\u3002
<van-action-sheet
- show="{{ show }}"
- actions="{{ actions }}"
- bind:close="onClose"
- bind:getuserinfo="onGetUserInfo"
-/>
-
Page({
- data: {
- show: false,
- actions: [
- { name: '\u83B7\u53D6\u7528\u6237\u4FE1\u606F', color: '#07c160', openType: 'getUserInfo' },
- ],
- },
-
- onClose() {
- this.setData({ show: false });
- },
-
- onGetUserInfo(e) {
- console.log(e.detail);
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u663E\u793A\u52A8\u4F5C\u9762\u677F | boolean | - |
actions | \u83DC\u5355\u9009\u9879 | Array | [] |
title | \u6807\u9898 | string | - |
description v1.0.0 | \u9009\u9879\u4E0A\u65B9\u7684\u63CF\u8FF0\u4FE1\u606F | string | - |
z-index | z-index \u5C42\u7EA7 | number | 100 |
cancel-text | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | - |
overlay | \u662F\u5426\u663E\u793A\u906E\u7F69\u5C42 | boolean | - |
round v1.0.0 | \u662F\u5426\u663E\u793A\u5706\u89D2 | boolean | true |
close-on-click-action | \u662F\u5426\u5728\u70B9\u51FB\u9009\u9879\u540E\u5173\u95ED | boolean | true |
close-on-click-overlay | \u70B9\u51FB\u906E\u7F69\u662F\u5426\u5173\u95ED\u83DC\u5355 | boolean | true |
safe-area-inset-bottom | \u662F\u5426\u4E3A iPhoneX \u7559\u51FA\u5E95\u90E8\u5B89\u5168\u8DDD\u79BB | boolean | true |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:select | \u9009\u4E2D\u9009\u9879\u65F6\u89E6\u53D1\uFF0C\u7981\u7528\u6216\u52A0\u8F7D\u72B6\u6001\u4E0B\u4E0D\u4F1A\u89E6\u53D1 | event.detail: \u9009\u9879\u5BF9\u5E94\u7684\u5BF9\u8C61 |
bind:close | \u5173\u95ED\u65F6\u89E6\u53D1 | - |
bind:cancel | \u53D6\u6D88\u6309\u94AE\u70B9\u51FB\u65F6\u89E6\u53D1 | - |
bind:click-overlay | \u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u89E6\u53D1 | - |
bind:getuserinfo | \u7528\u6237\u70B9\u51FB\u8BE5\u6309\u94AE\u65F6\uFF0C\u4F1A\u8FD4\u56DE\u83B7\u53D6\u5230\u7684\u7528\u6237\u4FE1\u606F\uFF0C\u56DE\u8C03\u7684 detail \u6570\u636E\u4E0E wx.getUserInfo \u8FD4\u56DE\u7684\u4E00\u81F4\uFF0CopenType="getUserInfo"\u65F6\u6709\u6548 | - |
bind:contact | \u5BA2\u670D\u6D88\u606F\u56DE\u8C03\uFF0CopenType="contact"\u65F6\u6709\u6548 | - |
bind:getphonenumber | \u83B7\u53D6\u7528\u6237\u624B\u673A\u53F7\u56DE\u8C03\uFF0CopenType="getPhoneNumber"\u65F6\u6709\u6548 | - |
bind:getrealtimephonenumber v1.10.21 | \u83B7\u53D6\u624B\u673A\u53F7\u5B9E\u65F6\u9A8C\u8BC1\u56DE\u8C03\uFF0CopenType="getRealtimePhoneNumber"\u65F6\u6709\u6548 | - |
bind:error | \u5F53\u4F7F\u7528\u5F00\u653E\u80FD\u529B\u65F6\uFF0C\u53D1\u751F\u9519\u8BEF\u7684\u56DE\u8C03\uFF0CopenType="launchApp"\u65F6\u6709\u6548 | - |
bind:launchapp | \u6253\u5F00 APP \u6210\u529F\u7684\u56DE\u8C03\uFF0CopenType="launchApp"\u65F6\u6709\u6548 | - |
bind:opensetting | \u5728\u6253\u5F00\u6388\u6743\u8BBE\u7F6E\u9875\u540E\u56DE\u8C03\uFF0CopenType="openSetting"\u65F6\u6709\u6548 | - |
API
\u4E2D\u7684actions
\u4E3A\u4E00\u4E2A\u5BF9\u8C61\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E00\u4E2A\u5BF9\u8C61\u914D\u7F6E\u6BCF\u4E00\u5217\uFF0C\u6BCF\u4E00\u5217\u6709\u4EE5\u4E0Bkey
\uFF1A
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u9898 | string | - |
subname | \u4E8C\u7EA7\u6807\u9898 | string | - |
color | \u9009\u9879\u6587\u5B57\u989C\u8272 | string | - |
loading | \u662F\u5426\u4E3A\u52A0\u8F7D\u72B6\u6001 | boolean | - |
disabled | \u662F\u5426\u4E3A\u7981\u7528\u72B6\u6001 | boolean | - |
className | \u4E3A\u5BF9\u5E94\u5217\u6DFB\u52A0\u989D\u5916\u7684 class \u7C7B\u540D | string | - |
openType | \u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0Czh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en |
sessionFrom | \u4F1A\u8BDD\u6765\u6E90\uFF0CopenType="contact"\u65F6\u6709\u6548 | string | - |
sendMessageTitle | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898\uFF0CopenType="contact"\u65F6\u6709\u6548 | string | \u5F53\u524D\u6807\u9898 |
sendMessagePath | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84\uFF0CopenType="contact"\u65F6\u6709\u6548 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 |
sendMessageImg | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u56FE\u7247\uFF0CopenType="contact"\u65F6\u6709\u6548 | string | \u622A\u56FE |
showMessageCard | \u662F\u5426\u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\uFF0C\u8BBE\u7F6E\u6B64\u53C2\u6570\u4E3A true\uFF0C\u7528\u6237\u8FDB\u5165\u5BA2\u670D\u4F1A\u8BDD\u4F1A\u5728\u53F3\u4E0B\u89D2\u663E\u793A"\u53EF\u80FD\u8981\u53D1\u9001\u7684\u5C0F\u7A0B\u5E8F"\u63D0\u793A\uFF0C\u7528\u6237\u70B9\u51FB\u540E\u53EF\u4EE5\u5FEB\u901F\u53D1\u9001\u5C0F\u7A0B\u5E8F\u6D88\u606F\uFF0CopenType="contact"\u65F6\u6709\u6548 | string | false |
appParameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570\uFF0CopenType=launchApp \u65F6\u6709\u6548 | string | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class v1.10.7 | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
list-class v1.10.7 | actions \u5BB9\u5668\u6837\u5F0F\u7C7B |
\u7701\u5E02\u533A\u9009\u62E9\u7EC4\u4EF6\u901A\u5E38\u4E0E \u5F39\u51FA\u5C42 \u7EC4\u4EF6\u914D\u5408\u4F7F\u7528\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-area": "@vant/weapp/area/index"
-}
-
\u521D\u59CB\u5316\u7701\u5E02\u533A\u7EC4\u4EF6\u65F6\uFF0C\u9700\u8981\u901A\u8FC7 area-list
\u5C5E\u6027\u4F20\u5165\u7701\u5E02\u533A\u6570\u636E\u3002
<van-area area-list="{{ areaList }}" />
-
areaList \u4E3A\u5BF9\u8C61\u7ED3\u6784\uFF0C\u5305\u542B province_list
\u3001city_list
\u3001county_list
\u4E09\u4E2A key\u3002
\u6BCF\u9879\u4EE5\u5730\u533A\u7801\u4F5C\u4E3A key\uFF0C\u7701\u5E02\u533A\u540D\u5B57\u4F5C\u4E3A value\u3002\u5730\u533A\u7801\u4E3A 6 \u4F4D\u6570\u5B57\uFF0C\u524D\u4E24\u4F4D\u4EE3\u8868\u7701\u4EFD\uFF0C\u4E2D\u95F4\u4E24\u4F4D\u4EE3\u8868\u57CE\u5E02\uFF0C\u540E\u4E24\u4F4D\u4EE3\u8868\u533A\u53BF\uFF0C\u4EE5 0 \u8865\u8DB3 6 \u4F4D\u3002\u6BD4\u5982\u5317\u4EAC\u7684\u5730\u533A\u7801\u4E3A 11
\uFF0C\u4EE5 0 \u8865\u8DB3 6 \u4F4D\uFF0C\u4E3A 110000
\u3002
\u793A\u4F8B\u6570\u636E\u5982\u4E0B\uFF1A
const areaList = {
- province_list: {
- 110000: '\u5317\u4EAC\u5E02',
- 120000: '\u5929\u6D25\u5E02',
- },
- city_list: {
- 110100: '\u5317\u4EAC\u5E02',
- 120100: '\u5929\u6D25\u5E02',
- },
- county_list: {
- 110101: '\u4E1C\u57CE\u533A',
- 110102: '\u897F\u57CE\u533A',
- // ....
- },
-};
-
Vant \u5B98\u65B9\u63D0\u4F9B\u4E86\u4E00\u4EFD\u9ED8\u8BA4\u7684\u7701\u5E02\u533A\u6570\u636E\uFF0C\u53EF\u4EE5\u901A\u8FC7 @vant/area-data \u5F15\u5165\u3002
yarn add @vant/area-data
-
import { areaList } from '@vant/area-data';
-
-Page({
- data: {
- areaList,
- },
-});
-
\u5982\u679C\u60F3\u9009\u4E2D\u67D0\u4E2A\u7701\u5E02\u533A\uFF0C\u9700\u8981\u4F20\u5165\u4E00\u4E2Avalue
\u5C5E\u6027\uFF0C\u7ED1\u5B9A\u5BF9\u5E94\u7684\u7701\u5E02\u533Acode
\u3002
<van-area area-list="{{ areaList }}" value="110101" />
-
\u53EF\u4EE5\u901A\u8FC7columns-num
\u5C5E\u6027\u914D\u7F6E\u7701\u5E02\u533A\u663E\u793A\u7684\u5217\u6570\uFF0C\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u663E\u793A\u7701\u5E02\u533A\uFF0C\u5F53\u4F60\u8BBE\u7F6E\u4E3A2
\uFF0C\u5219\u53EA\u4F1A\u663E\u793A\u7701\u5E02\u9009\u62E9\u3002
<van-area area-list="{{ areaList }}" columns-num="{{ 2 }}" title="\u6807\u9898" />
-
\u53EF\u4EE5\u901A\u8FC7columns-placeholder
\u5C5E\u6027\u914D\u7F6E\u6BCF\u4E00\u5217\u7684\u5360\u4F4D\u63D0\u793A\u6587\u5B57\u3002
<van-area
- area-list="{{ areaList }}"
- columns-placeholder="{{ ['\u8BF7\u9009\u62E9', '\u8BF7\u9009\u62E9', '\u8BF7\u9009\u62E9'] }}"
- title="\u6807\u9898"
-/>
-
\u5B9E\u9645\u9879\u76EE\u4E2D\uFF0C\u53EF\u4EE5\u901A\u8FC7\u5C0F\u7A0B\u5E8F\u4E91\u5F00\u53D1\u7684\u80FD\u529B\uFF0C\u5C06\u7701\u5E02\u533A\u6570\u636E\u4FDD\u5B58\u5728\u4E91\u5F00\u53D1\u7684\u6570\u636E\u5E93\u4E2D\uFF0C\u5E76\u5728\u5C0F\u7A0B\u5E8F\u4E2D\u4F7F\u7528\u4E91\u5F00\u53D1\u7684\u63A5\u53E3\u5F02\u6B65\u83B7\u53D6\u6570\u636E\u3002
\u5728\u5C0F\u7A0B\u5E8F\u4E2D\u4F7F\u7528\u4E91\u80FD\u529B\u4E4B\u524D\u9700\u8981\u5148\u8C03\u7528wx.could.init
\u65B9\u6CD5\u5B8C\u6210\u4E91\u80FD\u529B\u7684\u521D\u59CB\u5316\u3002
const db = wx.cloud.database();
-
-db.collection('region')
- .limit(1)
- .get()
- .then((res) => {
- if (res.data && res.data.length > 0) {
- this.setData({
- areaList: res.data[0],
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u9009\u4E2D\u7684\u7701\u5E02\u533Acode | string | - |
title | \u9876\u90E8\u680F\u6807\u9898 | string | - |
area-list | \u7701\u5E02\u533A\u6570\u636E\uFF0C\u683C\u5F0F\u89C1\u4E0B\u65B9 | object | - |
columns-num | \u7701\u5E02\u533A\u663E\u793A\u5217\u6570\uFF0C3-\u7701\u5E02\u533A\uFF0C2-\u7701\u5E02\uFF0C1-\u7701 | string | number | 3 |
columns-placeholder | \u5217\u5360\u4F4D\u63D0\u793A\u6587\u5B57 | string[] | [] |
loading | \u662F\u5426\u663E\u793A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
item-height | \u9009\u9879\u9AD8\u5EA6 | number | 44 |
visible-item-count | \u53EF\u89C1\u7684\u9009\u9879\u4E2A\u6570 | number | 6 |
confirm-button-text | \u786E\u8BA4\u6309\u94AE\u6587\u5B57 | string | \u786E\u8BA4 |
cancel-button-text | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | \u53D6\u6D88 |
show-toolbar 1.10.3 | \u662F\u5426\u663E\u793A\u9876\u90E8\u680F | boolean | true |
\u4E8B\u4EF6 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:confirm | \u70B9\u51FB\u53F3\u4E0A\u65B9\u5B8C\u6210\u6309\u94AE | \u4E00\u4E2A\u6570\u7EC4\u53C2\u6570\uFF0C\u5177\u4F53\u683C\u5F0F\u770B\u4E0B\u65B9\u6570\u636E\u683C\u5F0F\u7AE0\u8282 |
bind:cancel | \u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6 | - |
bind:change | \u9009\u9879\u6539\u53D8\u65F6\u89E6\u53D1 | Picker \u5B9E\u4F8B\uFF0C\u6240\u6709\u5217\u9009\u4E2D\u503C\uFF0C\u5F53\u524D\u5217\u5BF9\u5E94\u7684\u7D22\u5F15 |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 Area \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
reset | code: string | - | \u6839\u636E code \u91CD\u7F6E\u6240\u6709\u9009\u9879\uFF0C\u82E5\u4E0D\u4F20 code\uFF0C\u5219\u91CD\u7F6E\u5230\u7B2C\u4E00\u9879 |
\u8FD4\u56DE\u7684\u6570\u636E\u6574\u4F53\u4E3A\u4E00\u4E2A Object\uFF0C\u5305\u542B values
, index
\u4E24\u4E2A key\u3002
values
\u6574\u4F53\u4E3A\u4E00\u4E2A\u6570\u7EC4\uFF0C\u6570\u7EC4\u5185\u5305\u542B columnsNum
\u4E2A\u6570\u636E\uFF0C \u6BCF\u4E2A\u6570\u636E\u5BF9\u5E94\u4E00\u5217\u9009\u9879\u4E2D\u88AB\u9009\u4E2D\u7684\u6570\u636E\u3002
code
\u4EE3\u8868\u88AB\u9009\u4E2D\u7684\u5730\u533A\u7F16\u7801\uFF0C name
\u4EE3\u8868\u88AB\u9009\u4E2D\u7684\u5730\u533A\u540D\u79F0\u3002
[
- {
- code: '110000',
- name: '\u5317\u4EAC\u5E02',
- },
- {
- code: '110100',
- name: '\u5317\u4EAC\u5E02',
- },
- {
- code: '110101',
- name: '\u4E1C\u57CE\u533A',
- },
-];
-
index
\u4E3A\u4E00\u4E2A\u6570\u7EC4\uFF0C\u6570\u7EC4\u5185\u5305\u542B columnsNum
\u4E2A\u6570\u636E\uFF0C \u6BCF\u4E2A\u6570\u636E\u5BF9\u5E94\u4E00\u5217\u9009\u9879\u4E2D\u88AB\u9009\u4E2D\u9879\u7684\u5E8F\u53F7\u3002
\u6309\u94AE\u7528\u4E8E\u89E6\u53D1\u4E00\u4E2A\u64CD\u4F5C\uFF0C\u5982\u63D0\u4EA4\u8868\u5355\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-button": "@vant/weapp/button/index"
-}
-
\u652F\u6301default
\u3001primary
\u3001info
\u3001warning
\u3001danger
\u4E94\u79CD\u7C7B\u578B\uFF0C\u9ED8\u8BA4\u4E3Adefault
\u3002
<van-button type="default">\u9ED8\u8BA4\u6309\u94AE</van-button>
-<van-button type="primary">\u4E3B\u8981\u6309\u94AE</van-button>
-<van-button type="info">\u4FE1\u606F\u6309\u94AE</van-button>
-<van-button type="warning">\u8B66\u544A\u6309\u94AE</van-button>
-<van-button type="danger">\u5371\u9669\u6309\u94AE</van-button>
-
\u901A\u8FC7plain
\u5C5E\u6027\u5C06\u6309\u94AE\u8BBE\u7F6E\u4E3A\u6734\u7D20\u6309\u94AE\uFF0C\u6734\u7D20\u6309\u94AE\u7684\u6587\u5B57\u4E3A\u6309\u94AE\u989C\u8272\uFF0C\u80CC\u666F\u4E3A\u767D\u8272\u3002
<van-button plain type="primary">\u6734\u7D20\u6309\u94AE</van-button>
-<van-button plain type="info">\u6734\u7D20\u6309\u94AE</van-button>
-
\u8BBE\u7F6Ehairline
\u5C5E\u6027\u53EF\u4EE5\u5F00\u542F 0.5px \u8FB9\u6846\uFF0C\u57FA\u4E8E\u4F2A\u7C7B\u5B9E\u73B0\u3002
<van-button plain hairline type="primary">\u7EC6\u8FB9\u6846\u6309\u94AE</van-button>
-<van-button plain hairline type="info">\u7EC6\u8FB9\u6846\u6309\u94AE</van-button>
-
\u901A\u8FC7disabled
\u5C5E\u6027\u6765\u7981\u7528\u6309\u94AE\uFF0C\u6B64\u65F6\u6309\u94AE\u7684bind:click
\u4E8B\u4EF6\u4E0D\u4F1A\u89E6\u53D1\u3002
<van-button disabled type="primary">\u7981\u7528\u72B6\u6001</van-button>
-<van-button disabled type="info">\u7981\u7528\u72B6\u6001</van-button>
-
<van-button loading type="primary" />
-<van-button loading type="primary" loading-type="spinner" />
-<van-button loading type="info" loading-text="\u52A0\u8F7D\u4E2D..." />
-
<van-button square type="primary">\u65B9\u5F62\u6309\u94AE</van-button>
-<van-button round type="info">\u5706\u5F62\u6309\u94AE</van-button>
-
\u901A\u8FC7icon
\u5C5E\u6027\u8BBE\u7F6E\u6309\u94AE\u56FE\u6807\uFF0C\u652F\u6301 Icon \u7EC4\u4EF6\u91CC\u7684\u6240\u6709\u56FE\u6807\uFF0C\u4E5F\u53EF\u4EE5\u4F20\u5165\u56FE\u6807 URL\u3002
<van-button icon="star-o" type="primary" />
-<van-button icon="star-o" type="primary">\u6309\u94AE</van-button>
-<van-button icon="https://img.yzcdn.cn/vant/logo.png" type="info">
- \u6309\u94AE
-</van-button>
-
\u652F\u6301large
\u3001normal
\u3001small
\u3001mini
\u56DB\u79CD\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4\u4E3Anormal
\u3002
<van-button type="primary" size="large">\u5927\u53F7\u6309\u94AE</van-button>
-<van-button type="primary" size="normal">\u666E\u901A\u6309\u94AE</van-button>
-<van-button type="primary" size="small">\u5C0F\u578B\u6309\u94AE</van-button>
-<van-button type="primary" size="mini">\u8FF7\u4F60\u6309\u94AE</van-button>
-
\u901A\u8FC7block
\u5C5E\u6027\u53EF\u4EE5\u5C06\u6309\u94AE\u7684\u5143\u7D20\u7C7B\u578B\u8BBE\u7F6E\u4E3A\u5757\u7EA7\u5143\u7D20\u3002
<van-button type="primary" block>\u5757\u7EA7\u5143\u7D20</van-button>
-
\u901A\u8FC7color
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u6309\u94AE\u7684\u989C\u8272\u3002
<van-button color="#7232dd">\u5355\u8272\u6309\u94AE</van-button>
-<van-button color="#7232dd" plain>\u5355\u8272\u6309\u94AE</van-button>
-<van-button color="linear-gradient(to right, #4bb0ff, #6149f6)">
- \u6E10\u53D8\u8272\u6309\u94AE
-</van-button>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
id | \u6807\u8BC6\u7B26 | string | - |
type | \u6309\u94AE\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary info warning danger | string | default |
size | \u6309\u94AE\u5C3A\u5BF8\uFF0C\u53EF\u9009\u503C\u4E3A normal large small mini | string | normal |
color v1.0.0 | \u6309\u94AE\u989C\u8272\uFF0C\u652F\u6301\u4F20\u5165linear-gradient \u6E10\u53D8\u8272 | string | - |
icon | \u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
class-prefix | \u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u540C Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027 | string | van-icon |
plain | \u662F\u5426\u4E3A\u6734\u7D20\u6309\u94AE | boolean | false |
block | \u662F\u5426\u4E3A\u5757\u7EA7\u5143\u7D20 | boolean | false |
round | \u662F\u5426\u4E3A\u5706\u5F62\u6309\u94AE | boolean | false |
square | \u662F\u5426\u4E3A\u65B9\u5F62\u6309\u94AE | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u6309\u94AE | boolean | false |
hairline | \u662F\u5426\u4F7F\u7528 0.5px \u8FB9\u6846 | boolean | false |
loading | \u662F\u5426\u663E\u793A\u4E3A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
loading-text | \u52A0\u8F7D\u72B6\u6001\u63D0\u793A\u6587\u5B57 | string | - |
loading-type | \u52A0\u8F7D\u72B6\u6001\u56FE\u6807\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A spinner | string | circular |
loading-size | \u52A0\u8F7D\u56FE\u6807\u5927\u5C0F | string | 20px |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
open-type | \u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
app-parameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570 | string | - |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0C zh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en |
session-from | \u4F1A\u8BDD\u6765\u6E90 | string | - |
business-id | \u5BA2\u670D\u6D88\u606F\u5B50\u5546\u6237 id | number | - |
send-message-title | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898 | string | \u5F53\u524D\u6807\u9898 |
send-message-path | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 |
send-message-img | sendMessageImg | string | \u622A\u56FE |
show-message-card | \u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247 | string | false |
dataset | \u6309\u94AE dataset\uFF0Copen-type \u4E3A share \u65F6\uFF0C\u53EF\u5728 onShareAppMessage \u4E8B\u4EF6\u7684 event.target.dataset.detail \u4E2D\u770B\u5230\u4F20\u5165\u7684\u503C | any | - |
form-type | \u7528\u4E8E form \u7EC4\u4EF6\uFF0C\u53EF\u9009\u503C\u4E3Asubmit reset \uFF0C\u70B9\u51FB\u5206\u522B\u4F1A\u89E6\u53D1 form \u7EC4\u4EF6\u7684 submit/reset \u4E8B\u4EF6 | string | - |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u6309\u94AE\uFF0C\u4E14\u6309\u94AE\u72B6\u6001\u4E0D\u4E3A\u52A0\u8F7D\u6216\u7981\u7528\u65F6\u89E6\u53D1 | - |
bind:getuserinfo | \u7528\u6237\u70B9\u51FB\u8BE5\u6309\u94AE\u65F6\uFF0C\u4F1A\u8FD4\u56DE\u83B7\u53D6\u5230\u7684\u7528\u6237\u4FE1\u606F\uFF0C \u4ECE\u8FD4\u56DE\u53C2\u6570\u7684 detail \u4E2D\u83B7\u53D6\u5230\u7684\u503C\u540C wx.getUserInfo | - |
bind:contact | \u5BA2\u670D\u6D88\u606F\u56DE\u8C03 | - |
bind:getphonenumber | \u83B7\u53D6\u7528\u6237\u624B\u673A\u53F7\u56DE\u8C03 | - |
bind:getrealtimephonenumber v1.10.21 | \u83B7\u53D6\u624B\u673A\u53F7\u5B9E\u65F6\u9A8C\u8BC1\u56DE\u8C03\uFF0Copen-type=getRealtimePhoneNumber \u65F6\u6709\u6548 | - |
bind:error | \u5F53\u4F7F\u7528\u5F00\u653E\u80FD\u529B\u65F6\uFF0C\u53D1\u751F\u9519\u8BEF\u7684\u56DE\u8C03 | - |
bind:opensetting | \u5728\u6253\u5F00\u6388\u6743\u8BBE\u7F6E\u9875\u540E\u56DE\u8C03 | - |
bind:chooseavatar | \u5F53 open-type \u7684\u503C\u4E3A chooseAvatar \u65F6\uFF0C\u9009\u62E9\u5934\u50CF\u4E4B\u540E\u7684\u56DE\u8C03 |
Button \u63D0\u4F9B\u7684\u662F click \u4E8B\u4EF6\u800C\u4E0D\u662F\u539F\u751F tap \u4E8B\u4EF6\uFF0C\u6309\u94AE\u7981\u7528\u65F6\uFF0Cclick \u4E8B\u4EF6\u4E0D\u4F1A\u89E6\u53D1\uFF0Ctap \u4E8B\u4EF6\u4F9D\u7136\u4F1A\u89E6\u53D1\u3002
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
loading-class | \u52A0\u8F7D\u56FE\u6807\u6837\u5F0F\u7C7B |
\u65E5\u5386\u7EC4\u4EF6\u7528\u4E8E\u9009\u62E9\u65E5\u671F\u6216\u65E5\u671F\u533A\u95F4\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-calendar": "@vant/weapp/calendar/index"
-}
-
\u4E0B\u9762\u6F14\u793A\u4E86\u7ED3\u5408\u5355\u5143\u683C\u6765\u4F7F\u7528\u65E5\u5386\u7EC4\u4EF6\u7684\u7528\u6CD5\uFF0C\u65E5\u671F\u9009\u62E9\u5B8C\u6210\u540E\u4F1A\u89E6\u53D1confirm
\u4E8B\u4EF6\u3002
<van-cell title="\u9009\u62E9\u5355\u4E2A\u65E5\u671F" value="{{ date }}" bind:click="onDisplay" />
-<van-calendar show="{{ show }}" bind:close="onClose" bind:confirm="onConfirm" />
-
Page({
- data: {
- date: '',
- show: false,
- },
-
- onDisplay() {
- this.setData({ show: true });
- },
- onClose() {
- this.setData({ show: false });
- },
- formatDate(date) {
- date = new Date(date);
- return \`\${date.getMonth() + 1}/\${date.getDate()}\`;
- },
- onConfirm(event) {
- this.setData({
- show: false,
- date: this.formatDate(event.detail),
- });
- },
-});
-
\u8BBE\u7F6Etype
\u4E3Amultiple
\u540E\u53EF\u4EE5\u9009\u62E9\u591A\u4E2A\u65E5\u671F\uFF0C\u6B64\u65F6confirm
\u4E8B\u4EF6\u8FD4\u56DE\u7684 date \u4E3A\u6570\u7EC4\u7ED3\u6784\uFF0C\u6570\u7EC4\u5305\u542B\u82E5\u5E72\u4E2A\u9009\u4E2D\u7684\u65E5\u671F\u3002
<van-cell title="\u9009\u62E9\u591A\u4E2A\u65E5\u671F" value="{{ text }}" bind:click="onDisplay" />
-<van-calendar
- show="{{ show }}"
- type="multiple"
- bind:close="onClose"
- bind:confirm="onConfirm"
-/>
-
Page({
- data: {
- text: '',
- show: false,
- },
-
- onDisplay() {
- this.setData({ show: true });
- },
- onClose() {
- this.setData({ show: false });
- },
- onConfirm(event) {
- this.setData({
- show: false,
- text: \`\u9009\u62E9\u4E86 \${event.detail.length} \u4E2A\u65E5\u671F\`,
- });
- },
-});
-
\u8BBE\u7F6Etype
\u4E3Arange
\u540E\u53EF\u4EE5\u9009\u62E9\u65E5\u671F\u533A\u95F4\uFF0C\u6B64\u65F6confirm
\u4E8B\u4EF6\u8FD4\u56DE\u7684 date \u4E3A\u6570\u7EC4\u7ED3\u6784\uFF0C\u6570\u7EC4\u7B2C\u4E00\u9879\u4E3A\u5F00\u59CB\u65F6\u95F4\uFF0C\u7B2C\u4E8C\u9879\u4E3A\u7ED3\u675F\u65F6\u95F4\u3002
<van-cell title="\u9009\u62E9\u65E5\u671F\u533A\u95F4" value="{{ date }}" bind:click="onDisplay" />
-<van-calendar
- show="{{ show }}"
- type="range"
- bind:close="onClose"
- bind:confirm="onConfirm"
-/>
-
Page({
- data: {
- date: '',
- show: false,
- },
-
- onDisplay() {
- this.setData({ show: true });
- },
- onClose() {
- this.setData({ show: false });
- },
- formatDate(date) {
- date = new Date(date);
- return \`\${date.getMonth() + 1}/\${date.getDate()}\`;
- },
- onConfirm(event) {
- const [start, end] = event.detail;
- this.setData({
- show: false,
- date: \`\${this.formatDate(start)} - \${this.formatDate(end)}\`,
- });
- },
-});
-
Tips: \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u65E5\u671F\u533A\u95F4\u7684\u8D77\u6B62\u65F6\u95F4\u4E0D\u80FD\u4E3A\u540C\u4E00\u5929\uFF0C\u53EF\u4EE5\u901A\u8FC7\u8BBE\u7F6E allow-same-day \u5C5E\u6027\u6765\u5141\u8BB8\u9009\u62E9\u540C\u4E00\u5929\u3002
\u5C06show-confirm
\u8BBE\u7F6E\u4E3Afalse
\u53EF\u4EE5\u9690\u85CF\u786E\u8BA4\u6309\u94AE\uFF0C\u8FD9\u79CD\u60C5\u51B5\u4E0B\u9009\u62E9\u5B8C\u6210\u540E\u4F1A\u7ACB\u5373\u89E6\u53D1confirm
\u4E8B\u4EF6\u3002
<van-calendar show="{{ show }}" show-confirm="{{ false }}" />
-
\u901A\u8FC7color
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u65E5\u5386\u7684\u989C\u8272\uFF0C\u5BF9\u9009\u4E2D\u65E5\u671F\u548C\u5E95\u90E8\u6309\u94AE\u751F\u6548\u3002
<van-calendar show="{{ show }}" color="#07c160" />
-
\u901A\u8FC7min-date
\u548Cmax-date
\u5B9A\u4E49\u65E5\u5386\u7684\u8303\u56F4\uFF0C\u9700\u8981\u6CE8\u610F\u7684\u662Fmin-date
\u548Cmax-date
\u7684\u533A\u95F4\u4E0D\u5B9C\u8FC7\u5927\uFF0C\u5426\u5219\u4F1A\u9020\u6210\u4E25\u91CD\u7684\u6027\u80FD\u95EE\u9898\u3002
<van-calendar
- show="{{ show }}"
- min-date="{{ minDate }}"
- max-date="{{ maxDate }}"
-/>
-
Page({
- data: {
- show: false,
- minDate: new Date(2010, 0, 1).getTime(),
- maxDate: new Date(2010, 0, 31).getTime(),
- },
-});
-
\u901A\u8FC7confirm-text
\u8BBE\u7F6E\u6309\u94AE\u6587\u5B57\uFF0C\u901A\u8FC7confirm-disabled-text
\u8BBE\u7F6E\u6309\u94AE\u7981\u7528\u65F6\u7684\u6587\u5B57\u3002
<van-calendar
- show="{{ show }}"
- type="range"
- confirm-text="\u5B8C\u6210"
- confirm-disabled-text="\u8BF7\u9009\u62E9\u7ED3\u675F\u65F6\u95F4"
-/>
-
\u901A\u8FC7\u4F20\u5165formatter
\u51FD\u6570\u6765\u5BF9\u65E5\u5386\u4E0A\u6BCF\u4E00\u683C\u7684\u5185\u5BB9\u8FDB\u884C\u683C\u5F0F\u5316
<van-calendar show="{{ show }}" type="range" formatter="{{ formatter }}" />
-
Page({
- data: {
- formatter(day) {
- const month = day.date.getMonth() + 1;
- const date = day.date.getDate();
-
- if (month === 5) {
- if (date === 1) {
- day.topInfo = '\u52B3\u52A8\u8282';
- } else if (date === 4) {
- day.topInfo = '\u4E94\u56DB\u9752\u5E74\u8282';
- } else if (date === 11) {
- day.text = '\u4ECA\u5929';
- }
- }
-
- if (day.type === 'start') {
- day.bottomInfo = '\u5165\u4F4F';
- } else if (day.type === 'end') {
- day.bottomInfo = '\u79BB\u5E97';
- }
-
- return day;
- },
- },
-});
-
\u901A\u8FC7position
\u5C5E\u6027\u81EA\u5B9A\u4E49\u5F39\u51FA\u5C42\u7684\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3Atop
\u3001left
\u3001right
\u3002
<van-calendar show="{{ show }}" round="false" position="right" />
-
\u9009\u62E9\u65E5\u671F\u533A\u95F4\u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7max-range
\u5C5E\u6027\u6765\u6307\u5B9A\u6700\u591A\u53EF\u9009\u5929\u6570\uFF0C\u9009\u62E9\u7684\u8303\u56F4\u8D85\u8FC7\u6700\u591A\u53EF\u9009\u5929\u6570\u65F6\uFF0C\u4F1A\u5F39\u51FA\u76F8\u5E94\u7684\u63D0\u793A\u6587\u6848\u3002
<van-calendar type="range" max-range="{{ 3 }}" />
-
\u901A\u8FC7 first-day-of-week
\u5C5E\u6027\u8BBE\u7F6E\u4E00\u5468\u4ECE\u54EA\u5929\u5F00\u59CB\u3002
<van-calendar first-day-of-week="{{ 1 }}" />
-
\u5C06poppable
\u8BBE\u7F6E\u4E3Afalse
\uFF0C\u65E5\u5386\u4F1A\u76F4\u63A5\u5C55\u793A\u5728\u9875\u9762\u5185\uFF0C\u800C\u4E0D\u662F\u4EE5\u5F39\u5C42\u7684\u5F62\u5F0F\u51FA\u73B0\u3002
<van-calendar
- title="\u65E5\u5386"
- poppable="{{ false }}"
- show-confirm="{{ false }}"
- class="calendar"
-/>
-
.calendar {
- --calendar-height: 618px;
-}
-
Tips: \u6CE8\u610F\uFF0C\u5728\u81EA\u5B9A\u4E49calendar\u7684\u9AD8\u5EA6\u65F6\uFF0C\u9700\u8981\u786E\u4FDD\uFF0C\u6EDA\u52A8\u5230\u5F53\u524D\u6708\u4EFD\u65F6\uFF0C\u6240\u6709\u7684\u65E5\u671F\u8981\u5C55\u73B0\u5728.van-calendar__body\u5185\uFF0C\u5426\u5219\u53EF\u80FD\u4F1A\u51FA\u73B0\u6EDA\u52A8\u65F6\u5934\u90E8\u6708\u4EFD\u4E0E\u5F53\u524D\u6708\u4EFD\u4E0D\u540C\u6B65\u7684\u60C5\u51B5\u3002\u76EE\u524D\u5E73\u94FA\u578B\u9884\u8BBE\u9AD8\u5EA6618px,\u5F39\u7A97\u578B\u9AD8\u5EA690%\u3002
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
type | \u9009\u62E9\u7C7B\u578B:single \u8868\u793A\u9009\u62E9\u5355\u4E2A\u65E5\u671F\uFF0Cmultiple \u8868\u793A\u9009\u62E9\u591A\u4E2A\u65E5\u671F\uFF0Crange \u8868\u793A\u9009\u62E9\u65E5\u671F\u533A\u95F4 | string | single |
title | \u65E5\u5386\u6807\u9898 | string | \u65E5\u671F\u9009\u62E9 |
color | \u4E3B\u9898\u8272\uFF0C\u5BF9\u5E95\u90E8\u6309\u94AE\u548C\u9009\u4E2D\u65E5\u671F\u751F\u6548 | string | #ee0a24 |
min-date | \u53EF\u9009\u62E9\u7684\u6700\u5C0F\u65E5\u671F | timestamp | \u5F53\u524D\u65E5\u671F |
max-date | \u53EF\u9009\u62E9\u7684\u6700\u5927\u65E5\u671F | timestamp | \u5F53\u524D\u65E5\u671F\u7684\u516D\u4E2A\u6708\u540E |
default-date v1.10.21 | \u9ED8\u8BA4\u9009\u4E2D\u7684\u65E5\u671F\uFF0Ctype \u4E3Amultiple \u6216range \u65F6\u4E3A\u6570\u7EC4\uFF0C\u4F20\u5165 null \u8868\u793A\u9ED8\u8BA4\u4E0D\u9009\u62E9 | timestamp | timestamp[] | null | \u4ECA\u5929 |
row-height | \u65E5\u671F\u884C\u9AD8 | number | string | 64 |
formatter | \u65E5\u671F\u683C\u5F0F\u5316\u51FD\u6570 | (day: Day) => Day | - |
poppable | \u662F\u5426\u4EE5\u5F39\u5C42\u7684\u5F62\u5F0F\u5C55\u793A\u65E5\u5386 | boolean | true |
show-mark | \u662F\u5426\u663E\u793A\u6708\u4EFD\u80CC\u666F\u6C34\u5370 | boolean | true |
show-title | \u662F\u5426\u5C55\u793A\u65E5\u5386\u6807\u9898 | boolean | true |
show-subtitle | \u662F\u5426\u5C55\u793A\u65E5\u5386\u526F\u6807\u9898\uFF08\u5E74\u6708\uFF09 | boolean | true |
show-confirm | \u662F\u5426\u5C55\u793A\u786E\u8BA4\u6309\u94AE | boolean | true |
confirm-text | \u786E\u8BA4\u6309\u94AE\u7684\u6587\u5B57 | string | \u786E\u5B9A |
confirm-disabled-text | \u786E\u8BA4\u6309\u94AE\u5904\u4E8E\u7981\u7528\u72B6\u6001\u65F6\u7684\u6587\u5B57 | string | \u786E\u5B9A |
first-day-of-week | \u8BBE\u7F6E\u5468\u8D77\u59CB\u65E5 | 0~6 | 0 |
readonly v1.9.1 | \u662F\u5426\u4E3A\u53EA\u8BFB\u72B6\u6001\uFF0C\u53EA\u8BFB\u72B6\u6001\u4E0B\u4E0D\u80FD\u9009\u62E9\u65E5\u671F | boolean | false |
\u5F53 Calendar \u7684 poppable
\u4E3A true
\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B props:
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u663E\u793A\u65E5\u5386\u5F39\u7A97 | boolean | false |
position | \u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top right left | string | bottom |
round | \u662F\u5426\u663E\u793A\u5706\u89D2\u5F39\u7A97 | boolean | true |
close-on-click-overlay | \u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED | boolean | true |
safe-area-inset-bottom | \u662F\u5426\u5F00\u542F\u5E95\u90E8\u5B89\u5168\u533A\u9002\u914D | boolean | true |
\u5F53 Calendar \u7684 type
\u4E3A range
\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B props:
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
max-range | \u65E5\u671F\u533A\u95F4\u6700\u591A\u53EF\u9009\u5929\u6570\uFF0C\u9ED8\u8BA4\u65E0\u9650\u5236 | number | string | - |
range-prompt | \u8303\u56F4\u9009\u62E9\u8D85\u8FC7\u6700\u591A\u53EF\u9009\u5929\u6570\u65F6\u7684\u63D0\u793A\u6587\u6848 | string | null | \u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 xx \u5929 |
show-range-prompt | \u8303\u56F4\u9009\u62E9\u8D85\u8FC7\u6700\u591A\u53EF\u9009\u5929\u6570\u65F6\uFF0C\u662F\u5426\u5C55\u793A\u63D0\u793A\u6587\u6848 | boolean | true |
allow-same-day | \u662F\u5426\u5141\u8BB8\u65E5\u671F\u8303\u56F4\u7684\u8D77\u6B62\u65F6\u95F4\u4E3A\u540C\u4E00\u5929 | boolean | false |
\u5F53 Calendar \u7684 type
\u4E3A multiple
\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B props:
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
min-range | \u65E5\u671F\u6700\u5C11\u53EF\u9009\u5929\u6570 | number | string | 1 |
\u65E5\u5386\u4E2D\u7684\u6BCF\u4E2A\u65E5\u671F\u90FD\u5BF9\u5E94\u4E00\u4E2A Day \u5BF9\u8C61\uFF0C\u901A\u8FC7formatter
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49 Day \u5BF9\u8C61\u7684\u5185\u5BB9\u3002
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
date | \u65E5\u671F\u5BF9\u5E94\u7684 Date \u5BF9\u8C61 | Date |
type | \u65E5\u671F\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3Aselected \u3001start \u3001middle \u3001end \u3001disabled | string |
text | \u4E2D\u95F4\u663E\u793A\u7684\u6587\u5B57 | string |
topInfo | \u4E0A\u65B9\u7684\u63D0\u793A\u4FE1\u606F | string |
bottomInfo | \u4E0B\u65B9\u7684\u63D0\u793A\u4FE1\u606F | string |
className | \u81EA\u5B9A\u4E49 className | string |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:select | \u70B9\u51FB\u4EFB\u610F\u65E5\u671F\u65F6\u89E6\u53D1 | value: Date | Date[] |
bind:unselect | \u5F53 Calendar \u7684 type \u4E3A multiple \u65F6,\u70B9\u51FB\u5DF2\u9009\u4E2D\u7684\u65E5\u671F\u65F6\u89E6\u53D1 | value: Date |
bind:confirm | \u65E5\u671F\u9009\u62E9\u5B8C\u6210\u540E\u89E6\u53D1\uFF0C\u82E5show-confirm \u4E3Atrue \uFF0C\u5219\u70B9\u51FB\u786E\u8BA4\u6309\u94AE\u540E\u89E6\u53D1 | value: Date | Date[] |
bind:open | \u6253\u5F00\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1 | - |
bind:close | \u5173\u95ED\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1 | - |
bind:opened | \u6253\u5F00\u5F39\u51FA\u5C42\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1 | - |
bind:closed | \u5173\u95ED\u5F39\u51FA\u5C42\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1 | - |
bind:over-range | \u8303\u56F4\u9009\u62E9\u8D85\u8FC7\u6700\u591A\u53EF\u9009\u5929\u6570\u65F6\u89E6\u53D1 | - |
bind:click-subtitle v1.8.1 | \u70B9\u51FB\u65E5\u5386\u526F\u6807\u9898\u65F6\u89E6\u53D1 | WechatMiniprogram.TouchEvent |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49\u6807\u9898 |
footer | \u81EA\u5B9A\u4E49\u5E95\u90E8\u533A\u57DF\u5185\u5BB9 |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 Calendar \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u8BF4\u660E | \u53C2\u6570 | \u8FD4\u56DE\u503C |
---|---|---|---|
reset | \u91CD\u7F6E\u9009\u4E2D\u7684\u65E5\u671F\u5230\u9ED8\u8BA4\u503C | - | - |
\u5546\u54C1\u5361\u7247\uFF0C\u7528\u4E8E\u5C55\u793A\u5546\u54C1\u7684\u56FE\u7247\u3001\u4EF7\u683C\u7B49\u4FE1\u606F\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-card": "@vant/weapp/card/index"
-}
-
<van-card
- num="2"
- price="2.00"
- desc="\u63CF\u8FF0\u4FE1\u606F"
- title="\u5546\u54C1\u6807\u9898"
- thumb="{{ imageURL }}"
-/>
-
\u53EF\u4EE5\u901A\u8FC7\u63D2\u69FD\u6DFB\u52A0\u5B9A\u5236\u5185\u5BB9\u3002
<van-card
- num="2"
- tag="\u6807\u7B7E"
- price="10.00"
- desc="\u63CF\u8FF0\u4FE1\u606F"
- title="\u5546\u54C1\u6807\u9898"
- thumb="{{ imageURL }}"
->
- <view slot="footer">
- <van-button size="mini">\u6309\u94AE</van-button>
- <van-button size="mini">\u6309\u94AE</van-button>
- </view>
-</van-card>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
thumb | \u5DE6\u4FA7\u56FE\u7247 | string | - |
thumb-mode | \u5DE6\u4FA7\u56FE\u7247\u88C1\u526A\u3001\u7F29\u653E\u7684\u6A21\u5F0F\uFF0C\u53EF\u9009\u503C\u53C2\u8003\u5C0F\u7A0B\u5E8F image \u7EC4\u4EF6 mode \u5C5E\u6027\u503C | string | aspectFit |
title | \u6807\u9898 | string | - |
desc | \u63CF\u8FF0 | string | - |
tag | \u6807\u7B7E | string | - |
num | \u5546\u54C1\u6570\u91CF | string | number | - |
price | \u5546\u54C1\u4EF7\u683C | string | number | - |
origin-price | \u5546\u54C1\u5212\u7EBF\u539F\u4EF7 | string | number | - |
centered | \u5185\u5BB9\u662F\u5426\u5782\u76F4\u5C45\u4E2D | string | false |
currency | \u8D27\u5E01\u7B26\u53F7 | string | \xA5 |
thumb-link | \u70B9\u51FB\u5DE6\u4FA7\u56FE\u7247\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740 | string | - |
link-type | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo switchTab reLaunch | string | navigateTo |
lazy-load | \u662F\u5426\u5F00\u542F\u56FE\u7247\u61D2\u52A0\u8F7D | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49\u6807\u9898\u680F\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86title \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
desc | \u81EA\u5B9A\u4E49\u63CF\u8FF0\u680F\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86desc \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
num | \u81EA\u5B9A\u4E49\u6570\u91CF |
price | \u81EA\u5B9A\u4E49\u4EF7\u683C |
origin-price | \u81EA\u5B9A\u4E49\u5546\u54C1\u539F\u4EF7\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86origin-price \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
price-top | \u81EA\u5B9A\u4E49\u4EF7\u683C\u4E0A\u65B9\u533A\u57DF |
bottom | \u81EA\u5B9A\u4E49\u4EF7\u683C\u4E0B\u65B9\u533A\u57DF |
thumb | \u81EA\u5B9A\u4E49\u56FE\u7247\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86thumb \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
tag | \u81EA\u5B9A\u4E49\u56FE\u7247\u89D2\u6807\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86tag \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
tags | \u81EA\u5B9A\u4E49\u63CF\u8FF0\u4E0B\u65B9\u6807\u7B7E\u533A\u57DF |
footer | \u81EA\u5B9A\u4E49\u53F3\u4E0B\u89D2\u5185\u5BB9 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
thumb-class | \u5DE6\u4FA7\u56FE\u7247\u6837\u5F0F\u7C7B |
title-class | \u6807\u9898\u6837\u5F0F\u7C7B |
price-class | \u4EF7\u683C\u6837\u5F0F\u7C7B |
origin-price-class | \u5212\u7EBF\u539F\u4EF7\u6837\u5F0F\u7C7B |
desc-class | \u63CF\u8FF0\u6837\u5F0F\u7C7B |
num-class | \u6570\u91CF\u6837\u5F0F\u7C7B |
\u7EA7\u8054\u9009\u62E9\u6846\uFF0C\u7528\u4E8E\u591A\u5C42\u7EA7\u6570\u636E\u7684\u9009\u62E9\uFF0C\u5178\u578B\u573A\u666F\u4E3A\u7701\u5E02\u533A\u9009\u62E9\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-cascader": "@vant/weapp/cascader/index"
-}
-
\u7EA7\u8054\u9009\u62E9\u7EC4\u4EF6\u53EF\u4EE5\u642D\u914D Field \u548C Popup \u7EC4\u4EF6\u4F7F\u7528\uFF0C\u793A\u4F8B\u5982\u4E0B\uFF1A
<van-field
- value="{{ fieldValue }}"
- is-link
- readonly
- label="\u5730\u533A"
- placeholder="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- bind:tap="onClick"
-/>
-<van-popup show="{{ show }}" round position="bottom">
- <van-cascader
- wx:if="{{ show }}"
- value="{{ cascaderValue }}"
- title="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- options="{{ options }}"
- bind:close="onClose"
- bind:finish="onFinish"
- />
-</van-popup>
-
-const options = [
- {
- text: '\u6D59\u6C5F\u7701',
- value: '330000',
- children: [{ text: '\u676D\u5DDE\u5E02', value: '330100' }],
- },
- {
- text: '\u6C5F\u82CF\u7701',
- value: '320000',
- children: [{ text: '\u5357\u4EAC\u5E02', value: '320100' }],
- },
-];
-
-Page({
- data: {
- show: false,
- options,
- fieldValue: '',
- cascaderValue: '',
- },
-
- onClick() {
- this.setData({
- show: true,
- });
- },
-
- onClose() {
- this.setData({
- show: false,
- });
- },
-
- onFinish(e) {
- const { selectedOptions, value } = e.detail;
- const fieldValue = selectedOptions
- .map((option) => option.text || option.name)
- .join('/');
- this.setData({
- fieldValue,
- cascaderValue: value,
- })
- },
-});
-
\u901A\u8FC7 active-color
\u5C5E\u6027\u6765\u8BBE\u7F6E\u9009\u4E2D\u72B6\u6001\u7684\u9AD8\u4EAE\u989C\u8272\u3002
<van-cascader
- value="{{ cascaderValue }}"
- title="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- options="{{ options }}"
- active-color="#ee0a24"
- bind:close="onClose"
- bind:finish="onFinish"
-/>
-
\u53EF\u4EE5\u76D1\u542C change
\u4E8B\u4EF6\u5E76\u52A8\u6001\u8BBE\u7F6E options
\uFF0C\u5B9E\u73B0\u5F02\u6B65\u52A0\u8F7D\u9009\u9879\u3002
<van-field
- value="{{ fieldValue }}"
- is-link
- readonly
- label="\u5730\u533A"
- placeholder="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- bind:tap="onClick"
-/>
-<van-popup show="{{ show }}" round position="bottom">
- <van-cascader
- wx:if="{{ show }}"
- value="{{ cascaderValue }}"
- title="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- options="{{ options }}"
- bind:close="onClose"
- bind:change="onChange"
- bind:finish="onFinish"
- />
-</van-popup>
-
Page({
- data: {
- options: [
- {
- text: '\u6D59\u6C5F\u7701',
- value: '330000',
- children: [],
- }
- ];
- },
- onChange(e) {
- const { value } = e.detail;
- if (value === this.data.options[0].value) {
- setTimeout(() => {
- const children = [
- { text: '\u676D\u5DDE\u5E02', value: '330100' },
- { text: '\u5B81\u6CE2\u5E02', value: '330200' },
- ];
- this.setData({
- 'options[0].children': children,
- })
- }, 500);
- }
- },
-});
-
-
\u901A\u8FC7 field-names
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49 options
\u91CC\u7684\u5B57\u6BB5\u540D\u79F0\u3002
<van-cascader
- value="{{ code }}"
- title="\u8BF7\u9009\u62E9\u6240\u5728\u5730\u533A"
- options="{{ options }}"
- field-names="{{ fieldNames }}"
-/>
-
Page({
- data: {
- code: '',
- fieldNames: {
- text: 'name',
- value: 'code',
- children: 'items',
- },
- options: [
- {
- name: '\u6D59\u6C5F\u7701',
- code: '330000',
- items: [{ name: '\u676D\u5DDE\u5E02', code: '330100' }],
- },
- {
- name: '\u6C5F\u82CF\u7701',
- code: '320000',
- items: [{ name: '\u5357\u4EAC\u5E02', code: '320100' }],
- },
- ],
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u9876\u90E8\u6807\u9898 | string | - |
value | \u9009\u4E2D\u9879\u7684\u503C | string | number | - |
options | \u53EF\u9009\u9879\u6570\u636E\u6E90 | CascaderOption[] | [] |
placeholder | \u672A\u9009\u4E2D\u65F6\u7684\u63D0\u793A\u6587\u6848 | string | \u8BF7\u9009\u62E9 |
active-color | \u9009\u4E2D\u72B6\u6001\u7684\u9AD8\u4EAE\u989C\u8272 | string | #1989fa |
swipeable | \u662F\u5426\u5F00\u542F\u624B\u52BF\u5DE6\u53F3\u6ED1\u52A8\u5207\u6362 | boolean | false |
closeable | \u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807 | boolean | true |
show-header | \u662F\u5426\u5C55\u793A\u6807\u9898\u680F | boolean | true |
close-icon | \u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027 | string | cross |
field-names | \u81EA\u5B9A\u4E49 options \u7ED3\u6784\u4E2D\u7684\u5B57\u6BB5 | CascaderFieldNames | { text: 'text', value: 'value', children: 'children' } |
options
\u5C5E\u6027\u662F\u4E00\u4E2A\u7531\u5BF9\u8C61\u6784\u6210\u7684\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E2A\u5BF9\u8C61\u914D\u7F6E\u4E00\u4E2A\u53EF\u9009\u9879\uFF0C\u5BF9\u8C61\u53EF\u4EE5\u5305\u542B\u4EE5\u4E0B\u503C\uFF1A
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
text | \u9009\u9879\u6587\u5B57\uFF08\u5FC5\u586B\uFF09 | string |
value | \u9009\u9879\u5BF9\u5E94\u7684\u503C\uFF08\u5FC5\u586B\uFF09 | string | number |
color | \u9009\u9879\u6587\u5B57\u989C\u8272 | string |
children | \u5B50\u9009\u9879\u5217\u8868 | CascaderOption[] |
disabled | \u662F\u5426\u7981\u7528\u9009\u9879 | boolean |
className | \u4E3A\u5BF9\u5E94\u5217\u6DFB\u52A0\u989D\u5916\u7684 class | string | Array | object |
\u4E8B\u4EF6 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u9009\u4E2D\u9879\u53D8\u5316\u65F6\u89E6\u53D1 | event.detail\uFF1A{ value: string | number, selectedOptions: CascaderOption[], tabIndex: number } |
bind:finish | \u5168\u90E8\u9009\u9879\u9009\u62E9\u5B8C\u6210\u540E\u89E6\u53D1 | event.detail\uFF1A{ value: string | number, selectedOptions: CascaderOption[], tabIndex: number } |
bind:close | \u70B9\u51FB\u5173\u95ED\u56FE\u6807\u65F6\u89E6\u53D1 | - |
bind:click-tab | \u70B9\u51FB\u6807\u7B7E\u65F6\u89E6\u53D1 | event.detail\uFF1A{ tabIndex: number, title: string } |
\u540D\u79F0 | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
title | \u81EA\u5B9A\u4E49\u9876\u90E8\u6807\u9898 | - |
\u5355\u5143\u683C\u4E3A\u5217\u8868\u4E2D\u7684\u5355\u4E2A\u5C55\u793A\u9879\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-cell": "@vant/weapp/cell/index",
- "van-cell-group": "@vant/weapp/cell-group/index"
-}
-
Cell
\u53EF\u4EE5\u5355\u72EC\u4F7F\u7528\uFF0C\u4E5F\u53EF\u4EE5\u4E0ECellGroup
\u642D\u914D\u4F7F\u7528\u3002CellGroup
\u53EF\u4EE5\u4E3ACell
\u63D0\u4F9B\u4E0A\u4E0B\u5916\u8FB9\u6846\u3002
<van-cell-group>
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" label="\u63CF\u8FF0\u4FE1\u606F" border="{{ false }}" />
-</van-cell-group>
-
\u901A\u8FC7 CellGroup
\u7684 inset
\u5C5E\u6027\uFF0C\u53EF\u4EE5\u5C06\u5355\u5143\u683C\u8F6C\u6362\u4E3A\u5706\u89D2\u5361\u7247\u98CE\u683C\uFF08\u4ECE 1.7.2 \u7248\u672C\u5F00\u59CB\u652F\u6301\uFF09\u3002
<van-cell-group inset>
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" label="\u63CF\u8FF0\u4FE1\u606F" />
-</van-cell-group>
-
\u901A\u8FC7size
\u5C5E\u6027\u53EF\u4EE5\u63A7\u5236\u5355\u5143\u683C\u7684\u5927\u5C0F\u3002
<van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" size="large" />
-<van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" size="large" label="\u63CF\u8FF0\u4FE1\u606F" />
-
\u901A\u8FC7icon
\u5C5E\u6027\u5728\u6807\u9898\u5DE6\u4FA7\u5C55\u793A\u56FE\u6807\u3002
<van-cell title="\u5355\u5143\u683C" icon="location-o" />
-
\u8BBE\u7F6Eis-link
\u5C5E\u6027\u540E\u4F1A\u5728\u5355\u5143\u683C\u53F3\u4FA7\u663E\u793A\u7BAD\u5934\uFF0C\u5E76\u4E14\u53EF\u4EE5\u901A\u8FC7arrow-direction
\u5C5E\u6027\u63A7\u5236\u7BAD\u5934\u65B9\u5411\u3002
<van-cell title="\u5355\u5143\u683C" is-link />
-<van-cell title="\u5355\u5143\u683C" is-link value="\u5185\u5BB9" />
-<van-cell title="\u5355\u5143\u683C" is-link value="\u5185\u5BB9" arrow-direction="down" />
-
\u53EF\u4EE5\u901A\u8FC7url
\u5C5E\u6027\u8FDB\u884C\u9875\u9762\u8DF3\u8F6C\uFF0C\u901A\u8FC7link-type
\u5C5E\u6027\u63A7\u5236\u8DF3\u8F6C\u7C7B\u578B\u3002
<van-cell
- is-link
- title="\u5355\u5143\u683C"
- link-type="navigateTo"
- url="/pages/dashboard/index"
-/>
-
\u901A\u8FC7CellGroup
\u7684title
\u5C5E\u6027\u53EF\u4EE5\u6307\u5B9A\u5206\u7EC4\u6807\u9898\u3002
<van-cell-group title="\u5206\u7EC41">
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
-</van-cell-group>
-<van-cell-group title="\u5206\u7EC42">
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
-</van-cell-group>
-
\u5982\u4EE5\u4E0A\u7528\u6CD5\u4E0D\u80FD\u6EE1\u8DB3\u4F60\u7684\u9700\u6C42\uFF0C\u53EF\u4EE5\u4F7F\u7528\u63D2\u69FD\u6765\u81EA\u5B9A\u4E49\u5185\u5BB9\u3002
<van-cell value="\u5185\u5BB9" icon="shop-o" is-link>
- <view slot="title">
- <view class="van-cell-text">\u5355\u5143\u683C</view>
- <van-tag type="danger">\u6807\u7B7E</van-tag>
- </view>
-</van-cell>
-<van-cell title="\u5355\u5143\u683C">
- <van-icon slot="right-icon" name="search" class="custom-icon" />
-</van-cell>
-
\u901A\u8FC7center
\u5C5E\u6027\u53EF\u4EE5\u8BA9Cell
\u7684\u5DE6\u53F3\u5185\u5BB9\u90FD\u5782\u76F4\u5C45\u4E2D\u3002
<van-cell center title="\u5355\u5143\u683C" value="\u5185\u5BB9" label="\u63CF\u8FF0\u4FE1\u606F" />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u5206\u7EC4\u6807\u9898 | string | - |
inset v1.7.2 | \u662F\u5426\u5C55\u793A\u4E3A\u5706\u89D2\u5361\u7247\u98CE\u683C | boolean | false |
border | \u662F\u5426\u663E\u793A\u5916\u8FB9\u6846 | boolean | true |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
icon | \u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
title | \u5DE6\u4FA7\u6807\u9898 | string | number | - |
title-width | \u6807\u9898\u5BBD\u5EA6\uFF0C\u987B\u5305\u542B\u5355\u4F4D | string | - |
value | \u53F3\u4FA7\u5185\u5BB9 | string | number | - |
label | \u6807\u9898\u4E0B\u65B9\u7684\u63CF\u8FF0\u4FE1\u606F | string | - |
size | \u5355\u5143\u683C\u5927\u5C0F\uFF0C\u53EF\u9009\u503C\u4E3A large | string | - |
border | \u662F\u5426\u663E\u793A\u4E0B\u8FB9\u6846 | boolean | true |
center | \u662F\u5426\u4F7F\u5185\u5BB9\u5782\u76F4\u5C45\u4E2D | boolean | false |
url | \u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740 | string | - |
link-type | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo switchTab reLaunch | string | navigateTo |
clickable | \u662F\u5426\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | false |
is-link | \u662F\u5426\u5C55\u793A\u53F3\u4FA7\u7BAD\u5934\u5E76\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | false |
required | \u662F\u5426\u663E\u793A\u8868\u5355\u5FC5\u586B\u661F\u53F7 | boolean | false |
arrow-direction | \u7BAD\u5934\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A left up down | string | - |
use-label-slot | \u662F\u5426\u4F7F\u7528 label slot | boolean | false |
title-style v1.4.0 | \u6807\u9898\u6837\u5F0F | string | - |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u5355\u5143\u683C\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49value \u663E\u793A\u5185\u5BB9\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86value \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
title | \u81EA\u5B9A\u4E49title \u663E\u793A\u5185\u5BB9\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86title \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
label | \u81EA\u5B9A\u4E49label \u663E\u793A\u5185\u5BB9\uFF0C\u9700\u8981\u8BBE\u7F6E use-label-slot \u5C5E\u6027 |
icon | \u81EA\u5B9A\u4E49icon \u663E\u793A\u5185\u5BB9\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86icon \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
right-icon | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u6309\u94AE\uFF0C\u9ED8\u8BA4\u662Farrow \uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86is-link \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
title-class | \u6807\u9898\u6837\u5F0F\u7C7B |
label-class | \u63CF\u8FF0\u4FE1\u606F\u6837\u5F0F\u7C7B |
value-class | \u53F3\u4FA7\u5185\u5BB9\u6837\u5F0F\u7C7B |
\u5728\u4E00\u7EC4\u5907\u9009\u9879\u4E2D\u8FDB\u884C\u591A\u9009\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-checkbox": "@vant/weapp/checkbox/index",
- "van-checkbox-group": "@vant/weapp/checkbox-group/index"
-}
-
\u901A\u8FC7value
\u7ED1\u5B9A\u590D\u9009\u6846\u7684\u52FE\u9009\u72B6\u6001\u3002
<van-checkbox value="{{ checked }}" bind:change="onChange">\u590D\u9009\u6846</van-checkbox>
-
Page({
- data: {
- checked: true,
- },
-
- onChange(event) {
- this.setData({
- checked: event.detail,
- });
- },
-});
-
\u901A\u8FC7\u8BBE\u7F6Edisabled
\u5C5E\u6027\u53EF\u4EE5\u7981\u7528\u590D\u9009\u6846\u3002
<van-checkbox disabled value="{{ checked }}" bind:change="onChange">
- \u590D\u9009\u6846
-</van-checkbox>
-
\u5C06shape
\u5C5E\u6027\u8BBE\u7F6E\u4E3Asquare
\uFF0C\u590D\u9009\u6846\u7684\u5F62\u72B6\u4F1A\u53D8\u6210\u65B9\u5F62\u3002
<van-checkbox value="{{ checked }}" shape="square" bind:change="onChange">
- \u590D\u9009\u6846
-</van-checkbox>
-
\u901A\u8FC7checked-color
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u9009\u4E2D\u72B6\u6001\u4E0B\u7684\u56FE\u6807\u989C\u8272\u3002
<van-checkbox
- value="{{ checked }}"
- checked-color="#07c160"
- bind:change="onChange"
->
- \u590D\u9009\u6846
-</van-checkbox>
-
\u901A\u8FC7icon-size
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\u7684\u5927\u5C0F\u3002
<van-checkbox value="{{ checked }}" icon-size="25px">\u590D\u9009\u6846</van-checkbox>
-
\u901A\u8FC7 icon \u63D2\u69FD\u81EA\u5B9A\u4E49\u56FE\u6807\u3002
<van-checkbox use-icon-slot value="{{ checked }}" bind:change="onChange">
- \u81EA\u5B9A\u4E49\u56FE\u6807
- <image slot="icon" src="{{ checked ? activeIcon : inactiveIcon }}" />
-</van-checkbox>
-
Page({
- data: {
- checked: true,
- activeIcon: '//img.yzcdn.cn/icon-active.png',
- inactiveIcon: '//img.yzcdn.cn/icon-normal.png',
- },
-
- onChange(event) {
- this.setData({
- checked: event.detail,
- });
- },
-});
-
\u901A\u8FC7\u8BBE\u7F6Elabel-disabled
\u5C5E\u6027\u53EF\u4EE5\u7981\u7528\u590D\u9009\u6846\u6587\u672C\u70B9\u51FB\u3002
<van-checkbox value="{{ checked }}" label-disabled>\u590D\u9009\u6846</van-checkbox>
-
\u9700\u8981\u4E0Evan-checkbox-group
\u4E00\u8D77\u4F7F\u7528\uFF0C\u9009\u4E2D\u503C\u662F\u4E00\u4E2A\u6570\u7EC4\uFF0C\u901A\u8FC7value
\u7ED1\u5B9A\u5728van-checkbox-group
\u4E0A\uFF0C\u6570\u7EC4\u4E2D\u7684\u9879\u5373\u4E3A\u9009\u4E2D\u7684Checkbox
\u7684name
\u5C5E\u6027\u8BBE\u7F6E\u7684\u503C\u3002
<van-checkbox-group value="{{ result }}" bind:change="onChange">
- <van-checkbox name="a">\u590D\u9009\u6846 a</van-checkbox>
- <van-checkbox name="b">\u590D\u9009\u6846 b</van-checkbox>
- <van-checkbox name="c">\u590D\u9009\u6846 c</van-checkbox>
-</van-checkbox-group>
-
Page({
- data: {
- result: ['a', 'b'],
- },
-
- onChange(event) {
- this.setData({
- result: event.detail,
- });
- },
-});
-
<van-checkbox-group value="{{ result }}" bind:change="onChange" max="{{ 2 }}">
- <van-checkbox name="a">\u590D\u9009\u6846 a</van-checkbox>
- <van-checkbox name="b">\u590D\u9009\u6846 b</van-checkbox>
- <van-checkbox name="c">\u590D\u9009\u6846 c</van-checkbox>
-</van-checkbox-group>
-
\u6B64\u65F6\u4F60\u9700\u8981\u518D\u5F15\u5165Cell
\u548CCellGroup
\u7EC4\u4EF6\uFF0C\u5E76\u901A\u8FC7 checkbox \u7684 toggle \u65B9\u6CD5\u624B\u52A8\u89E6\u53D1\u5207\u6362\u3002
<van-checkbox-group value="{{ result }}" bind:change="onChange">
- <van-cell-group>
- <van-cell
- wx:for="{{ list }}"
- wx:key="index"
- title="\u590D\u9009\u6846 {{ item }}"
- value-class="value-class"
- clickable
- data-index="{{ index }}"
- bind:click="toggle"
- >
- <van-checkbox
- catch:tap="noop"
- class="checkboxes-{{ index }}"
- name="{{ item }}"
- />
- </van-cell>
- </van-cell-group>
-</van-checkbox-group>
-
Page({
- data: {
- list: ['a', 'b', 'c'],
- result: ['a', 'b'],
- },
-
- onChange(event) {
- this.setData({
- result: event.detail,
- });
- },
-
- toggle(event) {
- const { index } = event.currentTarget.dataset;
- const checkbox = this.selectComponent(\`.checkboxes-\${index}\`);
- checkbox.toggle();
- },
-
- noop() {},
-});
-
.value-class {
- flex: none !important;
-}
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u8BC6 Checkbox \u540D\u79F0 | string | - |
shape | \u5F62\u72B6\uFF0C\u53EF\u9009\u503C\u4E3A round square | string | round |
value | \u662F\u5426\u4E3A\u9009\u4E2D\u72B6\u6001 | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u5355\u9009\u6846 | boolean | false |
label-disabled | \u662F\u5426\u7981\u7528\u5355\u9009\u6846\u5185\u5BB9\u70B9\u51FB | boolean | false |
label-position | \u6587\u672C\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A left | string | right |
use-icon-slot | \u662F\u5426\u4F7F\u7528 icon slot | boolean | false |
checked-color | \u9009\u4E2D\u72B6\u6001\u989C\u8272 | string | #1989fa |
icon-size | icon \u5927\u5C0F | string | number | 20px |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
value | \u6240\u6709\u9009\u4E2D\u9879\u7684 name | Array | - |
disabled | \u662F\u5426\u7981\u7528\u6240\u6709\u5355\u9009\u6846 | boolean | false |
max | \u8BBE\u7F6E\u6700\u5927\u53EF\u9009\u6570 | number | 0 \uFF08\u65E0\u9650\u5236\uFF09 |
direction v1.7.0 | \u6392\u5217\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A horizontal | string | vertical |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u7ED1\u5B9A\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D\u7EC4\u4EF6\u7684\u503C |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
icon-class | \u56FE\u6807\u6837\u5F0F\u7C7B |
label-class | \u63CF\u8FF0\u4FE1\u606F\u6837\u5F0F\u7C7B |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u7ED1\u5B9A\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D\u7EC4\u4EF6\u7684\u503C |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u6587\u672C |
icon | \u81EA\u5B9A\u4E49\u56FE\u6807 |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 checkbox \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
toggle | - | - | \u5207\u6362\u9009\u4E2D\u72B6\u6001 |
\u5706\u73AF\u5F62\u7684\u8FDB\u5EA6\u6761\u7EC4\u4EF6\uFF0C\u652F\u6301\u8FDB\u5EA6\u6E10\u53D8\u52A8\u753B\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-circle": "@vant/weapp/circle/index"
-}
-
value
\u5C5E\u6027\u8868\u793A\u8FDB\u5EA6\u6761\u7684\u76EE\u6807\u8FDB\u5EA6\u3002
<van-circle value="{{ 30 }}" text="text" />
-
\u901A\u8FC7stroke-width
\u5C5E\u6027\u6765\u63A7\u5236\u8FDB\u5EA6\u6761\u5BBD\u5EA6\u3002
<van-circle value="{{ value }}" stroke-width="6" text="\u5BBD\u5EA6\u5B9A\u5236" />
-
\u901A\u8FC7color
\u5C5E\u6027\u6765\u63A7\u5236\u8FDB\u5EA6\u6761\u989C\u8272\uFF0Clayer-color
\u5C5E\u6027\u6765\u63A7\u5236\u8F68\u9053\u989C\u8272\u3002
<van-circle
- value="{{ value }}"
- layer-color="#eeeeee"
- color="#ee0a24"
- text="\u989C\u8272\u5B9A\u5236"
-/>
-
color
\u5C5E\u6027\u652F\u6301\u4F20\u5165\u5BF9\u8C61\u683C\u5F0F\u6765\u5B9A\u4E49\u6E10\u53D8\u8272\u3002
<van-circle value="{{ value }}" color="{{ gradientColor }}" text="\u6E10\u53D8\u8272" />
-
Page({
- data: {
- value: 25,
- gradientColor: {
- '0%': '#ffd01e',
- '100%': '#ee0a24',
- },
- },
-});
-
\u5C06clockwise
\u8BBE\u7F6E\u4E3Afalse
\uFF0C\u8FDB\u5EA6\u4F1A\u4ECE\u9006\u65F6\u9488\u65B9\u5411\u5F00\u59CB\u3002
<van-circle
- value="{{ value }}"
- color="#07c160"
- clockwise="{{ false }}"
- text="\u9006\u65F6\u9488"
-/>
-
\u901A\u8FC7size
\u5C5E\u6027\u8BBE\u7F6E\u5706\u73AF\u76F4\u5F84\u3002
<van-circle value="{{ value }}" size="120" text="\u5927\u5C0F\u5B9A\u5236" />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u76EE\u6807\u8FDB\u5EA6 | number | 0 |
type | \u6307\u5B9A canvas \u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A 2d | string | - |
size | \u5706\u73AF\u76F4\u5F84\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | number | 100 |
color | \u8FDB\u5EA6\u6761\u989C\u8272\uFF0C\u4F20\u5165\u5BF9\u8C61\u683C\u5F0F\u53EF\u4EE5\u5B9A\u4E49\u6E10\u53D8\u8272 | string | object | #1989fa |
layer-color | \u8F68\u9053\u989C\u8272 | string | #fff |
fill | \u586B\u5145\u989C\u8272 | string | - |
speed | \u52A8\u753B\u901F\u5EA6\uFF08\u5355\u4F4D\u4E3A value/s\uFF09 | number | 50 |
text | \u6587\u5B57 | string | - |
stroke-width | \u8FDB\u5EA6\u6761\u5BBD\u5EA6 | number | 4 |
clockwise | \u662F\u5426\u987A\u65F6\u9488\u589E\u52A0 | boolean | true |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u6587\u5B57\u5185\u5BB9\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86fill \uFF0C\u63D2\u69FD\u5185\u5BB9\u4F1A\u88AB\u539F\u751F\u7EC4\u4EF6\u8986\u76D6 |
Layout \u63D0\u4F9B\u4E86van-row
\u548Cvan-col
\u4E24\u4E2A\u7EC4\u4EF6\u6765\u8FDB\u884C\u884C\u5217\u5E03\u5C40\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-row": "@vant/weapp/row/index",
- "van-col": "@vant/weapp/col/index"
-}
-
Layout \u7EC4\u4EF6\u63D0\u4F9B\u4E8624\u5217\u6805\u683C
\uFF0C\u901A\u8FC7\u5728Col
\u4E0A\u6DFB\u52A0span
\u5C5E\u6027\u8BBE\u7F6E\u5217\u6240\u5360\u7684\u5BBD\u5EA6\u767E\u5206\u6BD4\u3002\u6B64\u5916\uFF0C\u6DFB\u52A0offset
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u5217\u7684\u504F\u79FB\u5BBD\u5EA6\uFF0C\u8BA1\u7B97\u65B9\u5F0F\u4E0E span \u76F8\u540C\u3002
<van-row>
- <van-col span="8">span: 8</van-col>
- <van-col span="8">span: 8</van-col>
- <van-col span="8">span: 8</van-col>
-</van-row>
-
-<van-row>
- <van-col span="4">span: 4</van-col>
- <van-col span="10" offset="4">offset: 4, span: 10</van-col>
-</van-row>
-
-<van-row>
- <van-col offset="12" span="12">offset: 12, span: 12</van-col>
-</van-row>
-
\u901A\u8FC7gutter
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u5217\u5143\u7D20\u4E4B\u95F4\u7684\u95F4\u8DDD\uFF0C\u9ED8\u8BA4\u95F4\u8DDD\u4E3A 0\u3002
<van-row gutter="20">
- <van-col span="8">span: 8</van-col>
- <van-col span="8">span: 8</van-col>
- <van-col span="8">span: 8</van-col>
-</van-row>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
gutter | \u5217\u5143\u7D20\u4E4B\u95F4\u7684\u95F4\u8DDD\uFF08\u5355\u4F4D\u4E3A px\uFF09 | string | number | - |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
span | \u5217\u5143\u7D20\u5BBD\u5EA6 | string | number | - |
offset | \u5217\u5143\u7D20\u504F\u79FB\u8DDD\u79BB | string | number | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u5C06\u4E00\u7EC4\u5185\u5BB9\u653E\u7F6E\u5728\u591A\u4E2A\u6298\u53E0\u9762\u677F\u4E2D\uFF0C\u70B9\u51FB\u9762\u677F\u7684\u6807\u9898\u53EF\u4EE5\u5C55\u5F00\u6216\u6536\u7F29\u5176\u5185\u5BB9\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-collapse": "@vant/weapp/collapse/index",
- "van-collapse-item": "@vant/weapp/collapse-item/index"
-}
-
\u901A\u8FC7value
\u63A7\u5236\u5C55\u5F00\u7684\u9762\u677F\u5217\u8868\uFF0CactiveNames
\u4E3A\u6570\u7EC4\u683C\u5F0F\u3002
<van-collapse value="{{ activeNames }}" bind:change="onChange">
- <van-collapse-item title="\u6807\u98981" name="1">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98982" name="2">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98983" name="3" disabled>
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
-</van-collapse>
-
Page({
- data: {
- activeNames: ['1'],
- },
- onChange(event) {
- this.setData({
- activeNames: event.detail,
- });
- },
-});
-
\u901A\u8FC7accordion
\u53EF\u4EE5\u8BBE\u7F6E\u4E3A\u624B\u98CE\u7434\u6A21\u5F0F\uFF0C\u6700\u591A\u5C55\u5F00\u4E00\u4E2A\u9762\u677F\uFF0C\u6B64\u65F6activeName
\u4E3A\u5B57\u7B26\u4E32\u683C\u5F0F\u3002
<van-collapse accordion value="{{ activeName }}" bind:change="onChange">
- <van-collapse-item title="\u6807\u98981" name="1">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98982" name="2">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98983" name="3">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
-</van-collapse>
-
Page({
- data: {
- activeName: '1',
- },
- onChange(event) {
- this.setData({
- activeName: event.detail,
- });
- },
-});
-
van-collapse
\u63D0\u4F9B\u4E86 change
, open
\u548C close
\u4E8B\u4EF6\u3002change
\u4E8B\u4EF6\u5728\u9762\u677F\u5207\u6362\u65F6\u89E6\u53D1\uFF0Copen
\u4E8B\u4EF6\u5728\u9762\u677F\u5C55\u5F00\u65F6\u89E6\u53D1\uFF0Cclose
\u4E8B\u4EF6\u5728\u9762\u677F\u5173\u95ED\u65F6\u89E6\u53D1\u3002
<van-collapse
- value="{{ activeNames }}"
- bind:change="onChange"
- bind:open="onOpen"
- bind:close="onClose"
->
- <van-collapse-item title="\u6807\u98981" name="1">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98982" name="2">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98983" name="3">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
-</van-collapse>
-
Page({
- data: {
- activeNames: ['1'],
- },
- onChange(event) {
- this.setData({
- activeNames: event.detail,
- });
- },
- onOpen(event) {
- Toast(\`\u5C55\u5F00: \${event.detail}\`);
- },
- onClose(event) {
- Toast(\`\u5173\u95ED: \${event.detail}\`);
- },
-});
-
<van-collapse value="{{ activeNames }}" bind:change="onChange">
- <van-collapse-item name="1">
- <view slot="title">\u6807\u98981<van-icon name="question-o" /></view>
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
- <van-collapse-item title="\u6807\u98982" name="2" icon="shop-o">
- \u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C
- </van-collapse-item>
-</van-collapse>
-
Page({
- data: {
- activeNames: ['1'],
- },
- onChange(event) {
- this.setData({
- activeNames: event.detail,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u5C55\u5F00\u9762\u677F\u7684 name | \u975E\u624B\u98CE\u7434\u6A21\u5F0F\uFF1A(string | number)[] \u624B\u98CE\u7434\u6A21\u5F0F\uFF1Astring | number | - |
accordion | \u662F\u5426\u5F00\u542F\u624B\u98CE\u7434\u6A21\u5F0F | boolean | false |
border | \u662F\u5426\u663E\u793A\u5916\u8FB9\u6846 | boolean | true |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
change | \u5207\u6362\u9762\u677F\u65F6\u89E6\u53D1 | activeNames: string | Array |
open | \u5C55\u5F00\u9762\u677F\u65F6\u89E6\u53D1 | currentName: string | number |
close | \u5173\u95ED\u9762\u677F\u65F6\u89E6\u53D1 | currentName: string | number |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u552F\u4E00\u6807\u8BC6\u7B26\uFF0C\u9ED8\u8BA4\u4E3A\u7D22\u5F15\u503C | string | number | index |
title | \u6807\u9898\u680F\u5DE6\u4FA7\u5185\u5BB9 | string | number | - |
size | \u6807\u9898\u680F\u5927\u5C0F\uFF0C\u53EF\u9009\u503C\u4E3Alarge | string | - |
icon | \u6807\u9898\u680F\u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
value | \u6807\u9898\u680F\u53F3\u4FA7\u5185\u5BB9 | string | number | - |
label | \u6807\u9898\u680F\u63CF\u8FF0\u4FE1\u606F | string | - |
border | \u662F\u5426\u663E\u793A\u5185\u8FB9\u6846 | boolean | true |
is-link | \u662F\u5426\u5C55\u793A\u6807\u9898\u680F\u53F3\u4FA7\u7BAD\u5934\u5E76\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | true |
clickable | \u662F\u5426\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u9762\u677F | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u9762\u677F\u5185\u5BB9 |
value | \u81EA\u5B9A\u4E49\u663E\u793A\u5185\u5BB9 |
icon | \u81EA\u5B9A\u4E49icon |
title | \u81EA\u5B9A\u4E49title |
right-icon | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u6309\u94AE\uFF0C\u9ED8\u8BA4\u662Farrow , \u9700\u8981\u5C06 is-link \u8BBE\u7F6E\u4E3A false , \u624D\u4F1A\u751F\u6548 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
content-class | \u5185\u5BB9\u6837\u5F0F\u7C7B |
Vant \u4E2D\u9ED8\u8BA4\u5305\u542B\u4E86\u4E00\u4E9B\u5E38\u7528\u6837\u5F0F\uFF0C\u53EF\u4EE5\u76F4\u63A5\u901A\u8FC7 className \u7684\u65B9\u5F0F\u4F7F\u7528\u3002
\u5728 app.wxss \u4E2D\u5F15\u5165\u5185\u7F6E\u6837\u5F0F\u3002
@import '@vant/weapp/common/index.wxss';
-
\u5F53\u6587\u672C\u5185\u5BB9\u957F\u5EA6\u8D85\u8FC7\u5BB9\u5668\u6700\u5927\u5BBD\u5EA6\u65F6\uFF0C\u81EA\u52A8\u7701\u7565\u591A\u4F59\u7684\u6587\u672C\u3002
<view class="van-ellipsis">
- \u8FD9\u662F\u4E00\u6BB5\u5BBD\u5EA6\u9650\u5236 250px \u7684\u6587\u5B57\uFF0C\u540E\u9762\u7684\u5185\u5BB9\u4F1A\u7701\u7565\u3002
-</view>
-
-<!-- \u6700\u591A\u663E\u793A\u4E24\u884C -->
-<view class="van-multi-ellipsis--l2">
- \u8FD9\u662F\u4E00\u6BB5\u6700\u591A\u663E\u793A\u4E24\u884C\u7684\u6587\u5B57\uFF0C\u540E\u9762\u7684\u5185\u5BB9\u4F1A\u7701\u7565\u3002
-</view>
-
-<!-- \u6700\u591A\u663E\u793A\u4E09\u884C -->
-<view class="van-multi-ellipsis--l3">
- \u8FD9\u662F\u4E00\u6BB5\u6700\u591A\u663E\u793A\u4E09\u884C\u7684\u6587\u5B57\uFF0C\u540E\u9762\u7684\u5185\u5BB9\u4F1A\u7701\u7565\u3002
-</view>
-
\u4E3A\u5143\u7D20\u6DFB\u52A0 Retina \u5C4F\u5E55\u4E0B\u7684 1px \u8FB9\u6846\uFF08\u5373 hairline\uFF09\uFF0C\u57FA\u4E8E\u4F2A\u7C7B transform \u5B9E\u73B0\u3002
<!-- \u4E0A\u8FB9\u6846 -->
-<view class="van-hairline--top"></view>
-
-<!-- \u4E0B\u8FB9\u6846 -->
-<view class="van-hairline--bottom"></view>
-
-<!-- \u5DE6\u8FB9\u6846 -->
-<view class="van-hairline--left"></view>
-
-<!-- \u53F3\u8FB9\u6846 -->
-<view class="van-hairline--right"></view>
-
-<!-- \u4E0A\u4E0B\u8FB9\u6846 -->
-<view class="van-hairline--top-bottom"></view>
-
-<!-- \u5168\u8FB9\u6846 -->
-<view class="van-hairline--surround"></view>
-
\u63A8\u8350\u5728 app.wxss \u4E2D\u8BBE\u7F6E\u4EE5\u4E0B\u5168\u5C40\u5B57\u4F53\uFF0C\u4EE5\u4FDD\u8BC1\u5728\u4E0D\u540C\u8BBE\u5907\u4E0A\u63D0\u4F9B\u6700\u4F73\u7684\u89C6\u89C9\u4F53\u9A8C\u3002
page {
- font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
- Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei',
- sans-serif;
-}
-
\u7528\u4E8E\u914D\u7F6E Vant Weapp \u7EC4\u4EF6\u7684\u4E3B\u9898\u6837\u5F0F\uFF0C\u4ECE v1.7.0
\u7248\u672C\u5F00\u59CB\u652F\u6301\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-config-provider": "@vant/weapp/config-provider/index"
-}
-
Vant Weapp \u7EC4\u4EF6\u901A\u8FC7\u4E30\u5BCC\u7684 CSS \u53D8\u91CF \u6765\u7EC4\u7EC7\u6837\u5F0F\uFF0C\u901A\u8FC7\u8986\u76D6\u8FD9\u4E9B CSS \u53D8\u91CF\uFF0C\u53EF\u4EE5\u5B9E\u73B0\u5B9A\u5236\u4E3B\u9898\u3001\u52A8\u6001\u5207\u6362\u4E3B\u9898\u7B49\u6548\u679C\u3002
\u4EE5 Button \u7EC4\u4EF6\u4E3A\u4F8B\uFF0C\u67E5\u770B\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u53EF\u4EE5\u770B\u5230 .van-button--primary
\u7C7B\u540D\u4E0A\u5B58\u5728\u4EE5\u4E0B\u53D8\u91CF\uFF1A
.van-button--primary {
- color: var(--button-primary-color, #fff);
- background: var(--button-primary-background-color, #07c160);
- border: var(--button-border-width, 1px) solid var(
- --button-primary-border-color,
- #07c160
- );
-}
-
\u4F60\u53EF\u4EE5\u76F4\u63A5\u5728\u4EE3\u7801\u4E2D\u8986\u76D6\u8FD9\u4E9B CSS \u53D8\u91CF\uFF0CButton \u7EC4\u4EF6\u7684\u6837\u5F0F\u4F1A\u968F\u4E4B\u53D1\u751F\u6539\u53D8\uFF1A
/* \u6DFB\u52A0\u8FD9\u6BB5\u6837\u5F0F\u540E\uFF0CPrimary Button \u4F1A\u53D8\u6210\u7EA2\u8272 */
-page {
- --button-primary-background-color: red;
-}
-
ConfigProvider
\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u8986\u76D6 CSS \u53D8\u91CF\u7684\u80FD\u529B\uFF0C\u4F60\u9700\u8981\u5728\u6839\u8282\u70B9\u5305\u88F9\u4E00\u4E2A ConfigProvider
\u7EC4\u4EF6\uFF0C\u5E76\u901A\u8FC7 theme-vars
\u5C5E\u6027\u6765\u914D\u7F6E\u4E00\u4E9B\u4E3B\u9898\u53D8\u91CF\u3002
<van-config-provider theme-vars="{{ themeVars }}">
- <van-cell-group>
- <van-field label="\u8BC4\u5206">
- <view slot="input" style="width: 100%">
- <van-rate
- model:value="{{ rate }}"
- data-key="rate"
- bind:change="onChange"
- />
- </view>
- </van-field>
- <van-field label="\u6ED1\u5757" border="{{ false }}">
- <view slot="input" style="width: 100%">
- <van-slider
- value="{{ slider }}"
- data-key="slider"
- bind:change="onChange"
- />
- </view>
- </van-field>
- </van-cell-group>
-
- <view style="margin: 16px">
- <van-button round block type="primary">\u63D0\u4EA4</van-button>
- </view>
-</van-config-provider>
-
import Page from '../../common/page';
-
-Page({
- data: {
- rate: 4,
- slider: 50,
- themeVars: {
- rateIconFullColor: '#07c160',
- sliderBarHeight: '4px',
- sliderButtonWidth: '20px',
- sliderButtonHeight: '20px',
- sliderActiveBackgroundColor: '#07c160',
- buttonPrimaryBorderColor: '#07c160',
- buttonPrimaryBackgroundColor: '#07c160',
- },
- },
-
- onChange(event) {
- const { key } = event.currentTarget.dataset;
- this.setData({
- [key]: event.detail,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
theme-vars | \u81EA\u5B9A\u4E49\u4E3B\u9898\u53D8\u91CF | object | - |
\u7528\u4E8E\u5B9E\u65F6\u5C55\u793A\u5012\u8BA1\u65F6\u6570\u503C\uFF0C\u652F\u6301\u6BEB\u79D2\u7CBE\u5EA6\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-count-down": "@vant/weapp/count-down/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
time
\u5C5E\u6027\u8868\u793A\u5012\u8BA1\u65F6\u603B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2\u3002
<van-count-down time="{{ time }}" />
-
Page({
- data: {
- time: 30 * 60 * 60 * 1000,
- },
-});
-
\u901A\u8FC7format
\u5C5E\u6027\u8BBE\u7F6E\u5012\u8BA1\u65F6\u6587\u672C\u7684\u5185\u5BB9\u3002
<van-count-down time="{{ time }}" format="DD \u5929 HH \u65F6 mm \u5206 ss \u79D2" />
-
\u5012\u8BA1\u65F6\u9ED8\u8BA4\u6BCF\u79D2\u6E32\u67D3\u4E00\u6B21\uFF0C\u8BBE\u7F6Emillisecond
\u5C5E\u6027\u53EF\u4EE5\u5F00\u542F\u6BEB\u79D2\u7EA7\u6E32\u67D3\u3002
<van-count-down millisecond time="{{ time }}" format="HH:mm:ss:SSS" />
-
\u8BBE\u7F6Euse-slot
\u5C5E\u6027\u540E\u53EF\u4EE5\u81EA\u5B9A\u4E49\u5012\u8BA1\u65F6\u6837\u5F0F\uFF0C\u9700\u8981\u901A\u8FC7bind:change
\u4E8B\u4EF6\u83B7\u53D6timeData
\u5BF9\u8C61\u5E76\u81EA\u884C\u6E32\u67D3\uFF0C\u683C\u5F0F\u89C1\u4E0B\u65B9\u8868\u683C\u3002
<van-count-down use-slot time="{{ time }}" bind:change="onChange">
- <text class="item">{{ timeData.hours }}</text>
- <text class="item">{{ timeData.minutes }}</text>
- <text class="item">{{ timeData.seconds }}</text>
-</van-count-down>
-
Page({
- data: {
- time: 30 * 60 * 60 * 1000,
- timeData: {},
- },
-
- onChange(e) {
- this.setData({
- timeData: e.detail,
- });
- },
-});
-
.item {
- display: inline-block;
- width: 22px;
- margin-right: 5px;
- color: #fff;
- font-size: 12px;
- text-align: center;
- background-color: #1989fa;
- border-radius: 2px;
-}
-
\u901A\u8FC7 selectComponent
\u9009\u62E9\u5668\u83B7\u53D6\u5230\u7EC4\u4EF6\u5B9E\u4F8B\u540E\uFF0C\u53EF\u4EE5\u8C03\u7528start
\u3001pause
\u3001reset
\u65B9\u6CD5\u3002
<van-count-down
- class="control-count-down"
- millisecond
- time="{{ 3000 }}"
- auto-start="{{ false }}"
- format="ss:SSS"
- bind:finish="finished"
-/>
-
-<van-grid clickable column-num="3">
- <van-grid-item text="\u5F00\u59CB" icon="play-circle-o" bindclick="start" />
- <van-grid-item text="\u6682\u505C" icon="pause-circle-o" bindclick="pause" />
- <van-grid-item text="\u91CD\u7F6E" icon="replay" bindclick="reset" />
-</van-grid>
-
Page({
- start() {
- const countDown = this.selectComponent('.control-count-down');
- countDown.start();
- },
-
- pause() {
- const countDown = this.selectComponent('.control-count-down');
- countDown.pause();
- },
-
- reset() {
- const countDown = this.selectComponent('.control-count-down');
- countDown.reset();
- },
-
- finished() {
- Toast('\u5012\u8BA1\u65F6\u7ED3\u675F');
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
time | \u5012\u8BA1\u65F6\u65F6\u957F\uFF0C\u5355\u4F4D\u6BEB\u79D2 | number | - |
format | \u65F6\u95F4\u683C\u5F0F\uFF0CDD-\u65E5\uFF0CHH-\u65F6\uFF0Cmm-\u5206\uFF0Css-\u79D2\uFF0CSSS-\u6BEB\u79D2 | string | HH:mm:ss |
auto-start | \u662F\u5426\u81EA\u52A8\u5F00\u59CB\u5012\u8BA1\u65F6 | boolean | true |
millisecond | \u662F\u5426\u5F00\u542F\u6BEB\u79D2\u7EA7\u6E32\u67D3 | boolean | false |
use-slot | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u6837\u5F0F\u63D2\u69FD | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:finish | \u5012\u8BA1\u65F6\u7ED3\u675F\u65F6\u89E6\u53D1 | - |
bind:change | \u65F6\u95F4\u53D8\u5316\u65F6\u89E6\u53D1\uFF0C\u4EC5\u5728\u5F00\u542Fuse-slot \u540E\u624D\u4F1A\u89E6\u53D1 | timeData |
\u540D\u79F0 | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
days | \u5269\u4F59\u5929\u6570 | number |
hours | \u5269\u4F59\u5C0F\u65F6 | number |
minutes | \u5269\u4F59\u5206\u949F | number |
seconds | \u5269\u4F59\u79D2\u6570 | number |
milliseconds | \u5269\u4F59\u6BEB\u79D2 | number |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 CountDown \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
start | - | - | \u5F00\u59CB\u5012\u8BA1\u65F6 |
pause | - | - | \u6682\u505C\u5012\u8BA1\u65F6 |
reset | - | - | \u91CD\u8BBE\u5012\u8BA1\u65F6\uFF0C\u82E5auto-start \u4E3Atrue \uFF0C\u91CD\u8BBE\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u5012\u8BA1\u65F6 |
\u7528\u4E8E\u9009\u62E9\u65F6\u95F4\uFF0C\u652F\u6301\u65E5\u671F\u3001\u65F6\u5206\u7B49\u65F6\u95F4\u7EF4\u5EA6\uFF0C\u901A\u5E38\u4E0E \u5F39\u51FA\u5C42 \u7EC4\u4EF6\u914D\u5408\u4F7F\u7528\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-datetime-picker": "@vant/weapp/datetime-picker/index"
-}
-
value
\u4E3A\u65F6\u95F4\u6233\u3002
<van-datetime-picker
- type="datetime"
- value="{{ currentDate }}"
- min-date="{{ minDate }}"
- max-date="{{ maxDate }}"
- bind:input="onInput"
-/>
-
Page({
- data: {
- minHour: 10,
- maxHour: 20,
- minDate: new Date().getTime(),
- maxDate: new Date(2019, 10, 1).getTime(),
- currentDate: new Date().getTime(),
- },
-
- onInput(event) {
- this.setData({
- currentDate: event.detail,
- });
- },
-});
-
value
\u4E3A\u65F6\u95F4\u6233\uFF0C\u901A\u8FC7\u4F20\u5165 formatter
\u51FD\u6570\u5BF9\u9009\u9879\u6587\u5B57\u8FDB\u884C\u5904\u7406\u3002
<van-datetime-picker
- type="date"
- value="{{ currentDate }}"
- bind:input="onInput"
- min-date="{{ minDate }}"
- formatter="{{ formatter }}"
-/>
-
Page({
- data: {
- currentDate: new Date().getTime(),
- minDate: new Date().getTime(),
- formatter(type, value) {
- if (type === 'year') {
- return \`\${value}\u5E74\`;
- }
- if (type === 'month') {
- return \`\${value}\u6708\`;
- }
- return value;
- },
- },
-
- onInput(event) {
- this.setData({
- currentDate: event.detail,
- });
- },
-});
-
value
\u4E3A\u65F6\u95F4\u6233\u3002
<van-datetime-picker
- type="year-month"
- value="{{ currentDate }}"
- min-date="{{ minDate }}"
- bind:input="onInput"
-/>
-
Page({
- data: {
- currentDate: new Date().getTime(),
- minDate: new Date().getTime(),
- },
-
- onInput(event) {
- this.setData({
- currentDate: event.detail,
- });
- },
-});
-
value
\u4E3A\u5B57\u7B26\u4E32\u3002
<van-datetime-picker
- type="time"
- value="{{ currentDate }}"
- min-hour="{{ minHour }}"
- max-hour="{{ maxHour }}"
- bind:input="onInput"
-/>
-
Page({
- data: {
- currentDate: '12:00',
- minHour: 10,
- maxHour: 20,
- },
-
- onInput(event) {
- this.setData({
- currentDate: event.detail,
- });
- },
-});
-
\u901A\u8FC7\u4F20\u5165 filter
\u51FD\u6570\uFF0C\u53EF\u4EE5\u5BF9\u9009\u9879\u6570\u7EC4\u8FDB\u884C\u8FC7\u6EE4\uFF0C\u5B9E\u73B0\u81EA\u5B9A\u4E49\u65F6\u95F4\u95F4\u9694\u3002
<van-datetime-picker
- type="time"
- value="{{ currentDate }}"
- filter="{{ filter }}"
-/>
-
Page({
- data: {
- currentDate: '12:00',
- filter(type, options) {
- if (type === 'minute') {
- return options.filter((option) => option % 5 === 0);
- }
-
- return options;
- },
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u9009\u4E2D\u503C | string | number | - |
type | \u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A date time year-month \u4E0D\u5EFA\u8BAE\u52A8\u6001\u4FEE\u6539 | string | datetime |
min-date | \u53EF\u9009\u7684\u6700\u5C0F\u65F6\u95F4\uFF0C\u7CBE\u786E\u5230\u5206\u949F | number | \u5341\u5E74\u524D |
max-date | \u53EF\u9009\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u7CBE\u786E\u5230\u5206\u949F | number | \u5341\u5E74\u540E |
min-hour | \u53EF\u9009\u7684\u6700\u5C0F\u5C0F\u65F6\uFF0C\u9488\u5BF9 time \u7C7B\u578B | number | 0 |
max-hour | \u53EF\u9009\u7684\u6700\u5927\u5C0F\u65F6\uFF0C\u9488\u5BF9 time \u7C7B\u578B | number | 23 |
min-minute | \u53EF\u9009\u7684\u6700\u5C0F\u5206\u949F\uFF0C\u9488\u5BF9 time \u7C7B\u578B | number | 0 |
max-minute | \u53EF\u9009\u7684\u6700\u5927\u5206\u949F\uFF0C\u9488\u5BF9 time \u7C7B\u578B | number | 59 |
filter | \u9009\u9879\u8FC7\u6EE4\u51FD\u6570(type \u53EF\u80FD\u503C\u4E3A year , month , day , hour , minute ) | (type, values) => values | - |
formatter | \u9009\u9879\u683C\u5F0F\u5316\u51FD\u6570(type \u53EF\u80FD\u503C\u4E3A year , month , day , hour , minute ) | (type, value) => value | - |
title | \u9876\u90E8\u680F\u6807\u9898 | string | '' |
show-toolbar | \u662F\u5426\u663E\u793A\u9876\u90E8\u680F | boolean | true |
loading | \u662F\u5426\u663E\u793A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
item-height | \u9009\u9879\u9AD8\u5EA6 | number | 44 |
confirm-button-text | \u786E\u8BA4\u6309\u94AE\u6587\u5B57 | string | \u786E\u8BA4 |
cancel-button-text | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | \u53D6\u6D88 |
visible-item-count | \u53EF\u89C1\u7684\u9009\u9879\u4E2A\u6570 | number | 6 |
\u4E8B\u4EF6\u540D\u79F0 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:input | \u5F53\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D value |
bind:change | \u5F53\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u7EC4\u4EF6\u5B9E\u4F8B |
bind:confirm | \u70B9\u51FB\u5B8C\u6210\u6309\u94AE\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D value |
bind:cancel | \u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | - |
\u5728change
\u4E8B\u4EF6\u4E2D\uFF0C\u53EF\u4EE5\u83B7\u53D6\u5230\u7EC4\u4EF6\u5B9E\u4F8B\uFF0C\u5BF9\u7EC4\u4EF6\u8FDB\u884C\u76F8\u5E94\u7684\u66F4\u65B0\u7B49\u64CD\u4F5C\uFF1A
\u51FD\u6570 | \u8BF4\u660E |
---|---|
getColumnValue(index) | \u83B7\u53D6\u5BF9\u5E94\u5217\u4E2D\u9009\u4E2D\u7684\u503C |
setColumnValue(index, value) | \u8BBE\u7F6E\u5BF9\u5E94\u5217\u4E2D\u9009\u4E2D\u7684\u503C |
getColumnValues(index) | \u83B7\u53D6\u5BF9\u5E94\u5217\u4E2D\u6240\u6709\u7684\u5907\u9009\u503C |
setColumnValues(index, values) | \u8BBE\u7F6E\u5BF9\u5E94\u5217\u4E2D\u6240\u6709\u7684\u5907\u9009\u503C |
getValues() | \u83B7\u53D6\u6240\u6709\u5217\u4E2D\u88AB\u9009\u4E2D\u7684\u503C\uFF0C\u8FD4\u56DE\u4E00\u4E2A\u6570\u7EC4 |
setValues(values) | values \u4E3A\u4E00\u4E2A\u6570\u7EC4\uFF0C\u8BBE\u7F6E\u6240\u6709\u5217\u4E2D\u88AB\u9009\u4E2D\u7684\u503C |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
active-class | \u9009\u4E2D\u9879\u6837\u5F0F\u7C7B |
toolbar-class | \u9876\u90E8\u680F\u6837\u5F0F\u7C7B |
column-class | \u5217\u6837\u5F0F\u7C7B |
\u5F39\u51FA\u6A21\u6001\u6846\uFF0C\u5E38\u7528\u4E8E\u6D88\u606F\u63D0\u793A\u3001\u6D88\u606F\u786E\u8BA4\uFF0C\u6216\u5728\u5F53\u524D\u9875\u9762\u5185\u5B8C\u6210\u7279\u5B9A\u7684\u4EA4\u4E92\u64CD\u4F5C\uFF0C\u652F\u6301\u51FD\u6570\u8C03\u7528\u548C\u7EC4\u4EF6\u8C03\u7528\u4E24\u79CD\u65B9\u5F0F\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-dialog": "@vant/weapp/dialog/index"
-}
-
\u7528\u4E8E\u63D0\u793A\u4E00\u4E9B\u6D88\u606F\uFF0C\u53EA\u5305\u542B\u4E00\u4E2A\u786E\u8BA4\u6309\u94AE\u3002
<van-dialog id="van-dialog" />
-
import Dialog from '@vant/weapp/dialog/dialog';
-
-Dialog.alert({
- title: '\u6807\u9898',
- message: '\u5F39\u7A97\u5185\u5BB9',
-}).then(() => {
- // on close
-});
-
-Dialog.alert({
- message: '\u5F39\u7A97\u5185\u5BB9',
-}).then(() => {
- // on close
-});
-
\u7528\u4E8E\u786E\u8BA4\u6D88\u606F\uFF0C\u5305\u542B\u53D6\u6D88\u548C\u786E\u8BA4\u6309\u94AE\u3002
<van-dialog id="van-dialog" />
-
import Dialog from '@vant/weapp/dialog/dialog';
-
-Dialog.confirm({
- title: '\u6807\u9898',
- message: '\u5F39\u7A97\u5185\u5BB9',
-})
- .then(() => {
- // on confirm
- })
- .catch(() => {
- // on cancel
- });
-
\u5C06 theme \u9009\u9879\u8BBE\u7F6E\u4E3A round-button
\u53EF\u4EE5\u5C55\u793A\u5706\u89D2\u6309\u94AE\u98CE\u683C\u7684\u5F39\u7A97\u3002
<van-dialog id="van-dialog" />
-
import Dialog from '@vant/weapp/dialog/dialog';
-
-Dialog.alert({
- title: '\u6807\u9898',
- message: '\u5F39\u7A97\u5185\u5BB9',
- theme: 'round-button',
-}).then(() => {
- // on close
-});
-
-Dialog.alert({
- message: '\u5F39\u7A97\u5185\u5BB9',
- theme: 'round-button',
-}).then(() => {
- // on close
-});
-
\u901A\u8FC7 beforeClose
\u5C5E\u6027\u53EF\u4EE5\u4F20\u5165\u4E00\u4E2A\u56DE\u8C03\u51FD\u6570\uFF0C\u5728\u5F39\u7A97\u5173\u95ED\u524D\u8FDB\u884C\u7279\u5B9A\u64CD\u4F5C\u3002
<van-dialog id="van-dialog" />
-
import Dialog from '@vant/weapp/dialog/dialog';
-
-const beforeClose = (action) =>
- new Promise((resolve) => {
- setTimeout(() => {
- if (action === 'confirm') {
- resolve(true);
- } else {
- // \u62E6\u622A\u53D6\u6D88\u64CD\u4F5C
- resolve(false);
- }
- }, 1000);
- });
-
-Dialog.confirm({
- title: '\u6807\u9898',
- message: '\u5F39\u7A97\u5185\u5BB9',
- beforeClose,
-});
-
\u5982\u679C\u9700\u8981\u5728\u5F39\u7A97\u5185\u5D4C\u5165\u7EC4\u4EF6\u6216\u5176\u4ED6\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7EC4\u4EF6\u8C03\u7528\u7684\u65B9\u5F0F\u3002
<van-dialog
- use-slot
- title="\u6807\u9898"
- show="{{ show }}"
- show-cancel-button
- confirm-button-open-type="getUserInfo"
- bind:close="onClose"
- bind:getuserinfo="getUserInfo"
->
- <image src="https://img.yzcdn.cn/1.jpg" />
-</van-dialog>
-
Page({
- data: {
- show: true,
- },
-
- getUserInfo(event) {
- console.log(event.detail);
- },
-
- onClose() {
- this.setData({ show: false });
- },
-});
-
\u5982\u679C\u9700\u8981\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u5EFA\u8BAE\u4F7F\u7528 custom-class
\u5B9E\u73B0\uFF0C\u4E0D\u5728\u63A8\u8350 className
\u5C5E\u6027\uFF08\u5728\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u4E2D\u4F7F\u7528\u5E76\u4E0D\u4F1A\u751F\u6548\uFF09\uFF0C\u4F7F\u7528\u65B9\u6CD5\u5982\u4E0B
<van-dialog
- title="\u6807\u9898"
- message="\u5F39\u7A97\u5185\u5BB9"
- show="{{ show }}"
- custom-class="my-custom-class"
-/>
-
<van-dialog id="van-dialog" custom-class="my-custom-class" />
-
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
Dialog | options | Promise | \u5C55\u793A\u5F39\u7A97 |
Dialog.alert | options | Promise | \u5C55\u793A\u6D88\u606F\u63D0\u793A\u5F39\u7A97 |
Dialog.confirm | options | Promise | \u5C55\u793A\u6D88\u606F\u786E\u8BA4\u5F39\u7A97 |
Dialog.setDefaultOptions | options | void | \u4FEE\u6539\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5BF9\u6240\u6709 Dialog \u751F\u6548 |
Dialog.resetDefaultOptions | - | void | \u91CD\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5BF9\u6240\u6709 Dialog \u751F\u6548 |
Dialog.close | - | void | \u5173\u95ED\u5F39\u7A97 |
Dialog.stopLoading | - | void | \u505C\u6B62\u6309\u94AE\u7684\u52A0\u8F7D\u72B6\u6001 |
\u901A\u8FC7\u51FD\u6570\u8C03\u7528 Dialog \u65F6\uFF0C\u652F\u6301\u4F20\u5165\u4EE5\u4E0B\u9009\u9879\uFF1A
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u6807\u9898 | string | - |
width | \u5F39\u7A97\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 320px |
message | \u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7\\n \u6362\u884C | string | - |
messageAlign | \u5185\u5BB9\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3Aleft right | string | center |
theme | \u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3Around-button | string | default |
zIndex | z-index \u5C42\u7EA7 | number | 100 |
className | \u81EA\u5B9A\u4E49\u7C7B\u540D\uFF0Cdialog \u5728\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u5185\u65F6\u65E0\u6548\uFF0C\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 custom-class \u4EE3\u66FF\uFF0C\u5C06\u5728 2.0.0 \u79FB\u9664 | string | '' |
customStyle | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | '' |
selector | \u81EA\u5B9A\u4E49\u9009\u62E9\u5668 | string | van-dialog |
showConfirmButton | \u662F\u5426\u5C55\u793A\u786E\u8BA4\u6309\u94AE | boolean | true |
showCancelButton | \u662F\u5426\u5C55\u793A\u53D6\u6D88\u6309\u94AE | boolean | false |
confirmButtonText | \u786E\u8BA4\u6309\u94AE\u7684\u6587\u6848 | string | \u786E\u8BA4 |
cancelButtonText | \u53D6\u6D88\u6309\u94AE\u7684\u6587\u6848 | string | \u53D6\u6D88 |
overlay | \u662F\u5426\u5C55\u793A\u906E\u7F69\u5C42 | boolean | true |
overlayStyle | \u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F | object | - |
closeOnClickOverlay | \u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u662F\u5426\u5173\u95ED\u5F39\u7A97 | boolean | false |
asyncClose | \u5DF2\u5E9F\u5F03\uFF0C\u5C06\u5728 2.0.0 \u79FB\u9664\uFF0C\u8BF7\u4F7F\u7528 beforeClose \u5C5E\u6027\u4EE3\u66FF | boolean | false |
beforeClose | \u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE false \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise | (action) => boolean | Promise<boolean> | - |
context | \u9009\u62E9\u5668\u7684\u9009\u62E9\u8303\u56F4\uFF0C\u53EF\u4EE5\u4F20\u5165\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u7684 this \u4F5C\u4E3A\u4E0A\u4E0B\u6587 | object | \u5F53\u524D\u9875\u9762 |
transition | \u52A8\u753B\u540D\u79F0\uFF0C\u53EF\u9009\u503C\u4E3Afade none | string | scale |
confirmButtonOpenType | \u786E\u8BA4\u6309\u94AE\u7684\u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
\u4F7F\u7528confirmButtonOpenType
\u540E\uFF0C\u652F\u6301\u4EE5\u4E0B\u9009\u9879\uFF1A
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C | open-type |
---|---|---|---|---|
appParameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570 | string | - | launchApp |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0C zh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en | getUserInfo |
sessionFrom | \u4F1A\u8BDD\u6765\u6E90 | string | - | contact |
businessId | \u5BA2\u670D\u6D88\u606F\u5B50\u5546\u6237 id | number | - | contact |
sendMessageTitle | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898 | string | \u5F53\u524D\u6807\u9898 | contact |
sendMessagePath | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 | contact |
sendMessageImg | sendMessageImg | string | \u622A\u56FE | contact |
showMessageCard | \u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247 | string | false | contact |
\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Dialog \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B Props:
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u663E\u793A\u5F39\u7A97 | boolean | - |
title | \u6807\u9898 | string | - |
width | \u5F39\u7A97\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 320px |
message | \u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7\\n \u6362\u884C | string | - |
theme | \u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3Around-button | string | default |
message-align | \u5185\u5BB9\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3Aleft right | string | center |
z-index | z-index \u5C42\u7EA7 | number | 100 |
class-name | \u81EA\u5B9A\u4E49\u7C7B\u540D\uFF0Cdialog \u5728\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u5185\u65F6\u65E0\u6548\uFF0C\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 custom-class \u4EE3\u66FF\uFF0C\u5C06\u5728 2.0.0 \u79FB\u9664 | string | '' |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | '' |
show-confirm-button | \u662F\u5426\u5C55\u793A\u786E\u8BA4\u6309\u94AE | boolean | true |
show-cancel-button | \u662F\u5426\u5C55\u793A\u53D6\u6D88\u6309\u94AE | boolean | false |
confirm-button-text | \u786E\u8BA4\u6309\u94AE\u7684\u6587\u6848 | string | \u786E\u8BA4 |
cancel-button-text | \u53D6\u6D88\u6309\u94AE\u7684\u6587\u6848 | string | \u53D6\u6D88 |
confirm-button-color | \u786E\u8BA4\u6309\u94AE\u7684\u5B57\u4F53\u989C\u8272 | string | #ee0a24 |
cancel-button-color | \u53D6\u6D88\u6309\u94AE\u7684\u5B57\u4F53\u989C\u8272 | string | #333 |
overlay | \u662F\u5426\u5C55\u793A\u906E\u7F69\u5C42 | boolean | true |
overlay-style v1.0.0 | \u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F | object | - |
close-on-click-overlay | \u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u662F\u5426\u5173\u95ED\u5F39\u7A97 | boolean | false |
use-slot | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u5185\u5BB9\u7684\u63D2\u69FD | boolean | false |
use-title-slot | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u6807\u9898\u7684\u63D2\u69FD | boolean | false |
use-confirm-button-slot 1.10.23 | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u786E\u8BA4\u6309\u94AE\u7684\u63D2\u69FD | boolean | false |
use-cancel-button-slot 1.10.23 | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u53D6\u6D88\u6309\u94AE\u7684\u63D2\u69FD | boolean | false |
async-close | \u5DF2\u5E9F\u5F03\uFF0C\u5C06\u5728 2.0.0 \u79FB\u9664\uFF0C\u8BF7\u4F7F\u7528 beforeClose \u5C5E\u6027\u4EE3\u66FF | boolean | false |
before-close | \u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE false \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise | (action) => boolean | Promise<boolean> | - |
transition | \u52A8\u753B\u540D\u79F0\uFF0C\u53EF\u9009\u503C\u4E3Afade | string | scale |
confirm-button-open-type | \u786E\u8BA4\u6309\u94AE\u7684\u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
\u4F7F\u7528confirm-button-open-type
\u540E\uFF0C\u652F\u6301\u4EE5\u4E0B Props\uFF1A
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C | open-type |
---|---|---|---|---|
app-parameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570 | string | - | launchApp |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0C zh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en | getUserInfo |
session-from | \u4F1A\u8BDD\u6765\u6E90 | string | - | contact |
business-id | \u5BA2\u670D\u6D88\u606F\u5B50\u5546\u6237 id | number | - | contact |
send-message-title | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898 | string | \u5F53\u524D\u6807\u9898 | contact |
send-message-path | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 | contact |
send-message-img | sendMessageImg | string | \u622A\u56FE | contact |
show-message-card | \u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247 | string | false | contact |
\u4E8B\u4EF6 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:close | \u5F39\u7A97\u5173\u95ED\u65F6\u89E6\u53D1 | event.detail: \u89E6\u53D1\u5173\u95ED\u4E8B\u4EF6\u7684\u6765\u6E90\uFF0C \u679A\u4E3E\u4E3A confirm ,cancel ,overlay |
bind:confirm | \u70B9\u51FB\u786E\u8BA4\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:cancel | \u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:getuserinfo | \u70B9\u51FB\u786E\u8BA4\u6309\u94AE\u65F6\uFF0C\u4F1A\u8FD4\u56DE\u83B7\u53D6\u5230\u7684\u7528\u6237\u4FE1\u606F\uFF0C \u4ECE\u8FD4\u56DE\u53C2\u6570\u7684 detail \u4E2D\u83B7\u53D6\u5230\u7684\u503C\u540C wx.getUserInfo | - |
bind:contact | \u5BA2\u670D\u6D88\u606F\u56DE\u8C03 | - |
bind:getphonenumber | \u83B7\u53D6\u7528\u6237\u624B\u673A\u53F7\u56DE\u8C03 | - |
bind:getrealtimephonenumber v1.10.21 | \u83B7\u53D6\u624B\u673A\u53F7\u5B9E\u65F6\u9A8C\u8BC1\u56DE\u8C03\uFF0Copen-type=getRealtimePhoneNumber \u65F6\u6709\u6548 | - |
bind:error | \u5F53\u4F7F\u7528\u5F00\u653E\u80FD\u529B\u65F6\uFF0C\u53D1\u751F\u9519\u8BEF\u7684\u56DE\u8C03 | - |
bind:opensetting | \u5728\u6253\u5F00\u6388\u6743\u8BBE\u7F6E\u9875\u540E\u56DE\u8C03 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49title \u663E\u793A\u5185\u5BB9\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86title \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
confirm-button 1.10.23 | \u81EA\u5B9A\u4E49confirm-button \u663E\u793A\u5185\u5BB9\uFF0C\u9700\u8981 use-confirm-button-slot \u4E3A true |
cancel-button 1.10.23 | \u81EA\u5B9A\u4E49cancel-button \u663E\u793A\u5185\u5BB9\uFF0C\u9700\u8981 use-cancel-button-slot \u4E3A true |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class v1.10.8 | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
cancle-button-class v1.10.21 | \u53D6\u6D88\u6309\u94AE\u6837\u5F0F\u7C7B |
confirm-button-class v1.10.21 | \u786E\u8BA4\u6309\u94AE\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5C06\u5185\u5BB9\u5206\u9694\u4E3A\u591A\u4E2A\u533A\u57DF\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u9ED8\u8BA4\u4E3AES6
\u7248\u672C\uFF0CES5
\u5F15\u5165\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
"usingComponents": {
- "van-divider": "@vant/weapp/divider/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
<van-divider />
-
<van-divider hairline />
-
<van-divider dashed />
-
<van-divider contentPosition="center">\u6587\u672C</van-divider>
-<van-divider contentPosition="left">\u6587\u672C</van-divider>
-<van-divider contentPosition="right">\u6587\u672C</van-divider>
-
<van-divider contentPosition="center" textColor="#1989fa">\u6587\u672C\u989C\u8272</van-divider>
-<van-divider contentPosition="center" borderColor="#1989fa">
- border \u989C\u8272
-</van-divider>
-<van-divider contentPosition="center" fontSize="18">\u5B57\u4F53\u5927\u5C0F</van-divider>
-
<van-divider
- contentPosition="center"
- customStyle="color: #1989fa; border-color: #1989fa; font-size: 18px;"
->
- \u6587\u672C
-</van-divider>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
dashed | \u865A\u7EBF | boolean | false |
hairline | \u7EC6\u7EBF | boolean | false |
content-position | \u6587\u672C\u4F4D\u7F6E\uFF0Cleft center right | string | - |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
\u9ED8\u8BA4 | \u81EA\u5B9A\u4E49\u6587\u672C\u5185\u5BB9 |
\u5411\u4E0B\u5F39\u51FA\u7684\u83DC\u5355\u5217\u8868\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u9ED8\u8BA4\u4E3AES6
\u7248\u672C\uFF0CES5
\u5F15\u5165\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
- "van-dropdown-item": "@vant/weapp/dropdown-item/index"
-}
-
<van-dropdown-menu>
- <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" />
- <van-dropdown-item value="{{ value2 }}" options="{{ option2 }}" />
-</van-dropdown-menu>
-
Page({
- data: {
- option1: [
- { text: '\u5168\u90E8\u5546\u54C1', value: 0 },
- { text: '\u65B0\u6B3E\u5546\u54C1', value: 1 },
- { text: '\u6D3B\u52A8\u5546\u54C1', value: 2 },
- ],
- option2: [
- { text: '\u9ED8\u8BA4\u6392\u5E8F', value: 'a' },
- { text: '\u597D\u8BC4\u6392\u5E8F', value: 'b' },
- { text: '\u9500\u91CF\u6392\u5E8F', value: 'c' },
- ],
- value1: 0,
- value2: 'a',
- },
-});
-
<van-dropdown-menu>
- <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" />
- <van-dropdown-item id="item" title="{{ itemTitle }}">
- <van-cell title="{{ switchTitle1 }}">
- <van-switch
- slot="right-icon"
- size="24px"
- style="height: 26px"
- checked="{{ switch1 }}"
- active-color="#ee0a24"
- bind:change="onSwitch1Change"
- />
- </van-cell>
- <van-cell title="{{ switchTitle2 }}">
- <van-switch
- slot="right-icon"
- size="24px"
- style="height: 26px"
- checked="{{ switch2 }}"
- active-color="#ee0a24"
- bind:change="onSwitch2Change"
- />
- </van-cell>
- <view style="padding: 5px 16px;">
- <van-button type="danger" block round bind:click="onConfirm">
- \u786E\u8BA4
- </van-button>
- </view>
- </van-dropdown-item>
-</van-dropdown-menu>
-
Page({
- data: {
- switchTitle1: '\u5305\u90AE',
- switchTitle2: '\u56E2\u8D2D',
- itemTitle: '\u7B5B\u9009',
- option1: [
- { text: '\u5168\u90E8\u5546\u54C1', value: 0 },
- { text: '\u65B0\u6B3E\u5546\u54C1', value: 1 },
- { text: '\u6D3B\u52A8\u5546\u54C1', value: 2 },
- ],
- value1: 0,
- },
-
- onConfirm() {
- this.selectComponent('#item').toggle();
- },
-
- onSwitch1Change({ detail }) {
- this.setData({ switch1: detail });
- },
-
- onSwitch2Change({ detail }) {
- this.setData({ switch2: detail });
- },
-});
-
<van-dropdown-menu active-color="#1989fa">
- <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" />
- <van-dropdown-item value="{{ value2 }}" options="{{ option2 }}" />
-</van-dropdown-menu>
-
<van-dropdown-menu direction="up">
- <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" />
- <van-dropdown-item value="{{ value2 }}" options="{{ option2 }}" />
-</van-dropdown-menu>
-
<van-dropdown-menu>
- <van-dropdown-item value="{{ value1 }}" disabled options="{{ option1 }}" />
- <van-dropdown-item value="{{ value2 }}" disabled options="{{ option2 }}" />
-</van-dropdown-menu>
-
\u901A\u8FC7 before-toggle
\u4E8B\u4EF6\u53EF\u4EE5\u5728\u4E0B\u62C9\u83DC\u5355\u6253\u5F00\u6216\u8005\u5173\u95ED\u524D\u6267\u884C\u7279\u5B9A\u7684\u903B\u8F91\uFF0C\u5B9E\u73B0\u72B6\u6001\u53D8\u66F4\u524D\u6821\u9A8C\u3001\u5F02\u6B65\u6253\u5F00/\u5173\u95ED\u7684\u76EE\u7684
<van-dropdown-menu>
- <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" use-before-toggle bind:before-toggle="onBeforeChange" />
-</van-dropdown-menu>
-
Page({
- data: {
- value1: 0,
- option1: [
- { text: '\u5168\u90E8\u5546\u54C1', value: 0 },
- { text: '\u65B0\u6B3E\u5546\u54C1', value: 1 },
- { text: '\u6D3B\u52A8\u5546\u54C1', value: 2 },
- ],
- },
- onBeforeChange({ detail: { status, callback }}) {
- wx.showModal({
- title: '\u5F02\u6B65\u6253\u5F00/\u5173\u95ED',
- content: \`\u786E\u5B9A\u8981\${status ? '\u6253\u5F00' : '\u5173\u95ED'}\u4E0B\u62C9\u83DC\u5355\u5417\uFF1F\`,
- success: (res) => {
- if (res.confirm) {
- callback(true)
- } else if (res.cancel) {
- callback(false)
- }
- },
- })
- }
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
active-color | \u83DC\u5355\u6807\u9898\u548C\u9009\u9879\u7684\u9009\u4E2D\u6001\u989C\u8272 | string | #ee0a24 |
z-index | \u83DC\u5355\u680F z-index \u5C42\u7EA7 | number | 10 |
duration | \u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u6BEB\u79D2 | number | 200 |
direction | \u83DC\u5355\u5C55\u5F00\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A up | string | down |
overlay | \u662F\u5426\u663E\u793A\u906E\u7F69\u5C42 | boolean | true |
safe-area-tab-bar v1.10.14 | \u662F\u5426\u7559\u51FA\u5E95\u90E8 tabbar \u5B89\u5168\u8DDD\u79BB | boolean | false |
close-on-click-overlay | \u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED\u83DC\u5355 | boolean | true |
close-on-click-outside | \u662F\u5426\u5728\u70B9\u51FB\u5916\u90E8 menu \u540E\u5173\u95ED\u83DC\u5355 | boolean | true |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u9009\u4E2D\u9879\u5BF9\u5E94\u7684 value | number | string | - |
title | \u83DC\u5355\u9879\u6807\u9898 | string | \u5F53\u524D\u9009\u4E2D\u9879\u6587\u5B57 |
options | \u9009\u9879\u6570\u7EC4 | Option[] | [] |
disabled | \u662F\u5426\u7981\u7528\u83DC\u5355 | boolean | false |
title-class | \u6807\u9898\u989D\u5916\u7C7B\u540D\uFF0C\u5EFA\u8BAE\u4F7F\u7528\u81EA\u5B9A\u4E49\u6837\u5F0F item-title-class \u4EE3\u66FF | string | - |
popup-style | \u81EA\u5B9A\u4E49\u5F39\u51FA\u5C42\u6837\u5F0F | string | - |
use-before-toggle v1.10.12 | \u662F\u5426\u5F00\u542F\u4E0B\u62C9\u83DC\u5355\u6253\u5F00\u6216\u8005\u5173\u95ED\u524D\u6821\u9A8C | boolean | false |
root-portal v1.10.14 | \u662F\u5426\u4ECE\u9875\u9762\u5B50\u6811\u4E2D\u8131\u79BB\u51FA\u6765\uFF0C\u7528\u4E8E\u89E3\u51B3\u5404\u79CD fixed \u5931\u6548\u95EE\u9898\uFF0C\u5FAE\u4FE1\u57FA\u7840\u5E93 >= 2.25.2 | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
change | \u70B9\u51FB\u9009\u9879\u5BFC\u81F4 value \u53D8\u5316\u65F6\u89E6\u53D1 | value |
open | \u6253\u5F00\u83DC\u5355\u680F\u65F6\u89E6\u53D1 | - |
close | \u5173\u95ED\u83DC\u5355\u680F\u65F6\u89E6\u53D1 | - |
opened | \u6253\u5F00\u83DC\u5355\u680F\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1 | - |
closed | \u5173\u95ED\u83DC\u5355\u680F\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1 | - |
before-toggle v1.10.12 | \u4E0B\u62C9\u83DC\u5355\u6253\u5F00\u6216\u8005\u5173\u95ED\u524D\u89E6\u53D1\uFF0C\u9700\u8981\u5C06use-before-toggle \u5C5E\u6027\u8BBE\u7F6E\u4E3Atrue | event.detail.status : true \u6253\u5F00\u4E0B\u62C9\u83DC\u5355\uFF0Cfalse \u5173\u95ED\u4E0B\u62C9\u83DC\u5355 event.detail.callback : \u56DE\u8C03\u51FD\u6570\uFF0C\u8C03\u7528callback(false) \u7EC8\u6B62\u4E0B\u62C9\u83DC\u5355\u72B6\u6001\u53D8\u66F4 |
\u901A\u8FC7 selectComponent(id) \u53EF\u8BBF\u95EE\u3002
\u65B9\u6CD5\u540D | \u8BF4\u660E | \u53C2\u6570 | \u8FD4\u56DE\u503C |
---|---|---|---|
toggle | \u5207\u6362\u83DC\u5355\u5C55\u793A\u72B6\u6001\uFF0C\u4F20true \u4E3A\u663E\u793A\uFF0Cfalse \u4E3A\u9690\u85CF\uFF0C\u4E0D\u4F20\u53C2\u4E3A\u53D6\u53CD | show?: boolean | - |
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
text | \u6587\u5B57 | string |
value | \u6807\u8BC6\u7B26 | number | string |
icon | \u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5 | string |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
title-class v1.10.7 | \u9009\u4E2D\u9879\u6837\u5F0F\u7C7B |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class v1.10.7 | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
item-title-class v1.10.7 | \u9009\u9879\u6837\u5F0F\u7C7B |
\u7A7A\u72B6\u6001\u65F6\u7684\u5360\u4F4D\u63D0\u793A\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u9ED8\u8BA4\u4E3AES6
\u7248\u672C\uFF0CES5
\u5F15\u5165\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-empty": "@vant/weapp/empty/index"
-}
-
<van-empty description="\u63CF\u8FF0\u6587\u5B57" />
-
Empty \u7EC4\u4EF6\u5185\u7F6E\u4E86\u591A\u79CD\u5360\u4F4D\u56FE\u7247\u7C7B\u578B\uFF0C\u53EF\u4EE5\u5728\u4E0D\u540C\u4E1A\u52A1\u573A\u666F\u4E0B\u4F7F\u7528\u3002
<!-- \u901A\u7528\u9519\u8BEF -->
-<van-empty image="error" description="\u63CF\u8FF0\u6587\u5B57" />
-<!-- \u7F51\u7EDC\u9519\u8BEF -->
-<van-empty image="network" description="\u63CF\u8FF0\u6587\u5B57" />
-<!-- \u641C\u7D22\u63D0\u793A -->
-<van-empty image="search" description="\u63CF\u8FF0\u6587\u5B57" />
-
\u9700\u8981\u81EA\u5B9A\u4E49\u56FE\u7247\u65F6\uFF0C\u53EF\u4EE5\u5728 image \u5C5E\u6027\u4E2D\u4F20\u5165\u4EFB\u610F\u56FE\u7247 URL\u3002
<van-empty
- class="custom-image"
- image="https://img.yzcdn.cn/vant/custom-empty-image.png"
- description="\u63CF\u8FF0\u6587\u5B57"
-/>
-
\u901A\u8FC7\u9ED8\u8BA4\u63D2\u69FD\u53EF\u4EE5\u5728 Empty \u7EC4\u4EF6\u7684\u4E0B\u65B9\u63D2\u5165\u5185\u5BB9\u3002
<van-empty description="\u63CF\u8FF0\u6587\u5B57">
- <van-button round type="danger" class="bottom-button">\u6309\u94AE</van-button>
-</van-empty>
-
-<style>
- .bottom-button {
- width: 160px;
- height: 40px;
- }
-</style>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
image | \u56FE\u7247\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A error network search \uFF0C\u652F\u6301\u4F20\u5165\u56FE\u7247 URL | string | default |
description | \u56FE\u7247\u4E0B\u65B9\u7684\u63CF\u8FF0\u6587\u5B57 | string | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u5E95\u90E8\u5185\u5BB9 |
image | \u81EA\u5B9A\u4E49\u56FE\u6807 |
description | \u81EA\u5B9A\u4E49\u63CF\u8FF0\u6587\u5B57 |
\u7528\u6237\u53EF\u4EE5\u5728\u6587\u672C\u6846\u5185\u8F93\u5165\u6216\u7F16\u8F91\u6587\u5B57\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-field": "@vant/weapp/field/index"
-}
-
<van-cell-group>
- <van-field
- value="{{ value }}"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- border="{{ false }}"
- bind:change="onChange"
- />
-</van-cell-group>
-
Page({
- data: {
- value: '',
- },
-
- onChange(event) {
- // event.detail \u4E3A\u5F53\u524D\u8F93\u5165\u7684\u503C
- console.log(event.detail);
- },
-});
-
\u6700\u4F4E\u57FA\u7840\u5E93\u7248\u672C\u5728 2.9.3 \u4EE5\u4E0A\u65F6\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7B80\u6613\u53CC\u5411\u7ED1\u5B9A\u3002
<van-cell-group>
- <van-field
- model:value="{{ value }}"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- border="{{ false }}"
- />
-</van-cell-group>
-
Page({
- data: {
- value: '',
- },
-});
-
\u6839\u636Etype
\u5C5E\u6027\u5B9A\u4E49\u4E0D\u540C\u7C7B\u578B\u7684\u8F93\u5165\u6846\u3002
<van-cell-group>
- <van-field
- value="{{ username }}"
- required
- clearable
- label="\u7528\u6237\u540D"
- icon="question-o"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- bind:click-icon="onClickIcon"
- />
-
- <van-field
- value="{{ password }}"
- type="password"
- label="\u5BC6\u7801"
- placeholder="\u8BF7\u8F93\u5165\u5BC6\u7801"
- required
- border="{{ false }}"
- />
-</van-cell-group>
-
<van-cell-group>
- <van-field
- value="\u8F93\u5165\u6846\u5DF2\u7981\u7528"
- label="\u7528\u6237\u540D"
- left-icon="contact"
- disabled
- border="{{ false }}"
- />
-</van-cell-group>
-
\u901A\u8FC7error
\u6216\u8005error-message
\u5C5E\u6027\u589E\u52A0\u5BF9\u5E94\u7684\u9519\u8BEF\u63D0\u793A\u3002
<van-cell-group>
- <van-field
- value="{{ username }}"
- label="\u7528\u6237\u540D"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- error
- />
- <van-field
- value="{{ phone }}"
- label="\u624B\u673A\u53F7"
- placeholder="\u8BF7\u8F93\u5165\u624B\u673A\u53F7"
- error-message="\u624B\u673A\u53F7\u683C\u5F0F\u9519\u8BEF"
- border="{{ false }}"
- />
-</van-cell-group>
-
\u53EF\u4EE5\u901A\u8FC7input-align
\u5C5E\u6027\u8BBE\u7F6E\u5185\u5BB9\u7684\u5BF9\u9F50\u65B9\u5F0F\u3002
<van-cell-group>
- <van-field
- value="{{ username3 }}"
- label="\u7528\u6237\u540D"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- input-align="right"
- />
-</van-cell-group>
-
\u5BF9\u4E8E textarea\uFF0C\u53EF\u4EE5\u901A\u8FC7autosize
\u5C5E\u6027\u8BBE\u7F6E\u9AD8\u5EA6\u81EA\u9002\u5E94\u3002
<van-cell-group>
- <van-field
- value="{{ message }}"
- label="\u7559\u8A00"
- type="textarea"
- placeholder="\u8BF7\u8F93\u5165\u7559\u8A00"
- autosize
- border="{{ false }}"
- />
-</van-cell-group>
-
\u901A\u8FC7 button slot \u53EF\u4EE5\u5728\u8F93\u5165\u6846\u5C3E\u90E8\u63D2\u5165\u6309\u94AE\u3002
<van-cell-group>
- <van-field
- value="{{ sms }}"
- center
- clearable
- label="\u77ED\u4FE1\u9A8C\u8BC1\u7801"
- placeholder="\u8BF7\u8F93\u5165\u77ED\u4FE1\u9A8C\u8BC1\u7801"
- border="{{ false }}"
- use-button-slot
- >
- <van-button slot="button" size="small" type="primary">
- \u53D1\u9001\u9A8C\u8BC1\u7801
- </van-button>
- </van-field>
-</van-cell-group>
-
\u5728\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u4E2D\uFF0Cbind:input \u4E8B\u4EF6\u53EF\u4EE5\u901A\u8FC7\u8FD4\u56DE\u5B57\u7B26\u4E32\u6216\u8005\u4E00\u4E2A\u5BF9\u8C61\u6765\u66FF\u6362\u8F93\u5165\u6846\u7684\u503C\u4EE5\u53CA\u8C03\u6574\u5149\u6807\u7684\u4F4D\u7F6E\uFF0C\u5728 vant-weapp \u4E2D\uFF0C\u53EF\u4EE5\u901A\u8FC7\u8C03\u7528 change \u6216 input \u53C2\u6570\u4E2D\u7684 callback \u51FD\u6570\uFF0C\u4F20\u5165\u53C2\u6570\u6765\u5B9E\u73B0
<van-field
- value="{{ value }}"
- placeholder="\u8BF7\u8F93\u5165\u7528\u6237\u540D"
- border="{{ false }}"
- clearable
- extra-event-params
- bind:change="onChange"
-/>
-
Page({
- data: {
- value: '',
- },
- onChange(e) {
- const { value, callback } = e.detail;
-
- callback({
- value: value + 1,
- cursor: 0,
- });
- },
-});
-
\u7531\u4E8E\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684 input \u7EC4\u4EF6\u548C textarea \u7EC4\u4EF6\u662F\u539F\u751F\u7EC4\u4EF6\uFF0C\u805A\u7126\u65F6\u4F1A\u5C06\u539F\u751F\u7684\u8F93\u5165\u6846\u8986\u76D6\u5728\u5BF9\u5E94\u4F4D\u7F6E\u4E0A\uFF0C\u5BFC\u81F4\u4E86\u8FD9\u4E2A\u73B0\u8C61\u7684\u4EA7\u751F\u3002
\u76F8\u5173\u7684\u8BA8\u8BBA\u53EF\u4EE5\u67E5\u770B\u5FAE\u4FE1\u5F00\u653E\u793E\u533A\u3002
\u7531\u4E8E\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684 input \u7EC4\u4EF6\u548C textarea \u7EC4\u4EF6\u662F\u539F\u751F\u7EC4\u4EF6\uFF0C\u9075\u5FAA\u539F\u751F\u7EC4\u4EF6\u7684\u9650\u5236\uFF0C\u8BE6\u60C5\u53EF\u4EE5\u67E5\u770B\u539F\u751F\u7EC4\u4EF6\u8BF4\u660E\u3002
\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684 textarea \u7EC4\u4EF6\u5728 Android \u548C iOS \u4E2D\u9ED8\u8BA4\u6837\u5F0F\u4E0D\u540C\uFF0C\u5728 iOS \u4E2D\u4F1A\u6709\u9ED8\u8BA4\u7684 padding
\uFF0C\u4E14\u65E0\u6CD5\u7F6E 0\u3002
\u540C\u65F6 placeholder-style
\u5BF9 vertical-align
\u3001line-height
\u7B49\u5927\u91CF css \u5C5E\u6027\u90FD\u4E0D\u751F\u6548\u3002
\u8FD9\u4E00\u7CFB\u5217\u7684\u95EE\u9898\u5BFC\u81F4\u4E86 placeholder \u5728\u771F\u673A\u4E0A\u53EF\u80FD\u4F1A\u51FA\u73B0\u504F\u79FB\u3002
\u5FAE\u4FE1\u5DF2\u7ECF\u5728 2.10.0
\u57FA\u7840\u5E93\u7248\u672C\u540E\u652F\u6301\u79FB\u9664\u9ED8\u8BA4\u7684 padding
\uFF0C\u4F46\u4F4E\u7248\u672C\u4ECD\u6709\u95EE\u9898\u3002\u8BE6\u60C5\u53EF\u4EE5\u67E5\u770B \u5FAE\u4FE1\u5F00\u653E\u793E\u533A\u3002
\u8FD9\u662F\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u7684 input \u7EC4\u4EF6\u672C\u8EAB\u7684\u95EE\u9898\uFF0C\u5982\u679C\u9700\u8981\u517C\u5BB9\u624B\u5199\u8F93\u5165\u6CD5\u7684\u573A\u666F\uFF0C\u53EF\u4EE5\u5728 blur
\u4E8B\u4EF6\u4E2D\u53D6\u5230\u8F93\u5165\u7684\u503C\u3002
\u76F8\u5173\u7684\u8BA8\u8BBA\u53EF\u4EE5\u67E5\u770B\u5FAE\u4FE1\u5F00\u653E\u793E\u533A\u3002
\u5347\u7EA7\u81F3 1.10.21 \u7248\u672C\u53CA\u4EE5\u4E0A\uFF0C\u914D\u7F6E name
\u5C5E\u6027\u5373\u53EF
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26\u3002\u53EF\u4EE5\u901A\u8FC7\u914D\u7F6E name \u6765\u6269\u5927\u70B9\u51FB\u533A\u57DF | string | - |
label | \u8F93\u5165\u6846\u5DE6\u4FA7\u6587\u672C | string | - |
size | \u5355\u5143\u683C\u5927\u5C0F\uFF0C\u53EF\u9009\u503C\u4E3A large | string | - |
value | \u5F53\u524D\u8F93\u5165\u7684\u503C | string | number | - |
type | \u53EF\u8BBE\u7F6E\u4E3A\u4EFB\u610F\u539F\u751F\u7C7B\u578B, \u5982 number idcard textarea digit | string | text |
fixed | \u5982\u679C type \u4E3A textarea \u4E14\u5728\u4E00\u4E2A position:fixed \u7684\u533A\u57DF\uFF0C\u9700\u8981\u663E\u793A\u6307\u5B9A\u5C5E\u6027 fixed \u4E3A true | boolean | false |
focus | \u83B7\u53D6\u7126\u70B9 | boolean | false |
border | \u662F\u5426\u663E\u793A\u5185\u8FB9\u6846 | boolean | true |
disabled | \u662F\u5426\u7981\u7528\u8F93\u5165\u6846 | boolean | false |
readonly | \u662F\u5426\u53EA\u8BFB | boolean | false |
clearable | \u662F\u5426\u542F\u7528\u6E05\u9664\u63A7\u4EF6 | boolean | false |
clickable | \u662F\u5426\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | false |
required | \u662F\u5426\u663E\u793A\u8868\u5355\u5FC5\u586B\u661F\u53F7 | boolean | false |
center | \u662F\u5426\u4F7F\u5185\u5BB9\u5782\u76F4\u5C45\u4E2D | boolean | false |
password | \u662F\u5426\u662F\u5BC6\u7801\u7C7B\u578B | boolean | false |
title-width | \u6807\u9898\u5BBD\u5EA6 | string | 6.2em |
maxlength | \u6700\u5927\u8F93\u5165\u957F\u5EA6\uFF0C\u8BBE\u7F6E\u4E3A -1 \u7684\u65F6\u5019\u4E0D\u9650\u5236\u6700\u5927\u957F\u5EA6 | number | -1 |
placeholder | \u8F93\u5165\u6846\u4E3A\u7A7A\u65F6\u5360\u4F4D\u7B26 | string | - |
placeholder-style | \u6307\u5B9A placeholder \u7684\u6837\u5F0F | string | - |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
is-link | \u662F\u5426\u5C55\u793A\u53F3\u4FA7\u7BAD\u5934\u5E76\u5F00\u542F\u70B9\u51FB\u53CD\u9988 | boolean | false |
arrow-direction | \u7BAD\u5934\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A left up down | string | - |
show-word-limit | \u662F\u5426\u663E\u793A\u5B57\u6570\u7EDF\u8BA1\uFF0C\u9700\u8981\u8BBE\u7F6Emaxlength \u5C5E\u6027 | boolean | false |
error | \u662F\u5426\u5C06\u8F93\u5165\u5185\u5BB9\u6807\u7EA2 | boolean | false |
error-message | \u5E95\u90E8\u9519\u8BEF\u63D0\u793A\u6587\u6848\uFF0C\u4E3A\u7A7A\u65F6\u4E0D\u5C55\u793A | string | '' |
error-message-align | \u5E95\u90E8\u9519\u8BEF\u63D0\u793A\u6587\u6848\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A center right | string | '' |
input-align | \u8F93\u5165\u6846\u5185\u5BB9\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A center right | string | left |
autosize | \u662F\u5426\u81EA\u9002\u5E94\u5185\u5BB9\u9AD8\u5EA6\uFF0C\u53EA\u5BF9 textarea \u6709\u6548\uFF0C \u53EF\u4F20\u5165\u5BF9\u8C61,\u5982 { maxHeight: 100, minHeight: 50 }\uFF0C \u5355\u4F4D\u4E3A px | boolean | object | false |
left-icon | \u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
right-icon | \u53F3\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
confirm-type | \u8BBE\u7F6E\u952E\u76D8\u53F3\u4E0B\u89D2\u6309\u94AE\u7684\u6587\u5B57\uFF0C\u4EC5\u5728 type='text' \u65F6\u751F\u6548 | string | done |
confirm-hold | \u70B9\u51FB\u952E\u76D8\u53F3\u4E0B\u89D2\u6309\u94AE\u65F6\u662F\u5426\u4FDD\u6301\u952E\u76D8\u4E0D\u6536\u8D77\uFF0C\u5728 type='textarea' \u65F6\u65E0\u6548 | boolean | false |
hold-keyboard | focus \u65F6\uFF0C\u70B9\u51FB\u9875\u9762\u7684\u65F6\u5019\u4E0D\u6536\u8D77\u952E\u76D8 | boolean | false |
cursor-spacing | \u8F93\u5165\u6846\u805A\u7126\u65F6\u5E95\u90E8\u4E0E\u952E\u76D8\u7684\u8DDD\u79BB | number | 50 |
adjust-position | \u952E\u76D8\u5F39\u8D77\u65F6\uFF0C\u662F\u5426\u81EA\u52A8\u4E0A\u63A8\u9875\u9762 | boolean | true |
show-confirm-bar | \u662F\u5426\u663E\u793A\u952E\u76D8\u4E0A\u65B9\u5E26\u6709\u201D\u5B8C\u6210\u201C\u6309\u94AE\u90A3\u4E00\u680F\uFF0C\u53EA\u5BF9 textarea \u6709\u6548 | boolean | true |
selection-start | \u5149\u6807\u8D77\u59CB\u4F4D\u7F6E\uFF0C\u81EA\u52A8\u805A\u96C6\u65F6\u6709\u6548\uFF0C\u9700\u4E0E selection-end \u642D\u914D\u4F7F\u7528 | number | -1 |
selection-end | \u5149\u6807\u7ED3\u675F\u4F4D\u7F6E\uFF0C\u81EA\u52A8\u805A\u96C6\u65F6\u6709\u6548\uFF0C\u9700\u4E0E selection-start \u642D\u914D\u4F7F\u7528 | number | -1 |
auto-focus | \u81EA\u52A8\u805A\u7126\uFF0C\u62C9\u8D77\u952E\u76D8 | boolean | false |
disable-default-padding | \u662F\u5426\u53BB\u6389 iOS \u4E0B\u7684\u9ED8\u8BA4\u5185\u8FB9\u8DDD\uFF0C\u53EA\u5BF9 textarea \u6709\u6548 | boolean | true |
cursor | \u6307\u5B9A focus \u65F6\u7684\u5149\u6807\u4F4D\u7F6E | number | -1 |
clear-trigger v1.8.4 | \u663E\u793A\u6E05\u9664\u56FE\u6807\u7684\u65F6\u673A\uFF0Calways \u8868\u793A\u8F93\u5165\u6846\u4E0D\u4E3A\u7A7A\u65F6\u5C55\u793A\uFF0Cfocus \u8868\u793A\u8F93\u5165\u6846\u805A\u7126\u4E14\u4E0D\u4E3A\u7A7A\u65F6\u5C55\u793A | string | focus |
always-embed v1.9.2 | \u5F3A\u5236 input \u5904\u4E8E\u540C\u5C42\u72B6\u6001\uFF0C\u9ED8\u8BA4 focus \u65F6 input \u4F1A\u5207\u5230\u975E\u540C\u5C42\u72B6\u6001 (\u4EC5\u5728 iOS \u4E0B\u751F\u6548) | boolean | false |
extra-event-params v1.10.12 | \u5F00\u542F\u4E8B\u4EF6\u589E\u5F3A\u6A21\u5F0F\uFF0C\u4F1A\u5728 input \u548C change \u4E8B\u4EF6\u989D\u5916\u63D0\u4F9B cursor \u548C keyCode \u53C2\u6570\uFF0C\u8BA1\u5212\u5728\u4E0B\u4E00\u4E2A\u5927\u7248\u672C\u4F5C\u4E3A\u9ED8\u8BA4\u884C\u4E3A | boolean | false |
\u4E8B\u4EF6 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:input | \u8F93\u5165\u5185\u5BB9\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u8F93\u5165\u503C; \u5728 extra-event-params \u4E3A true \u65F6\u4E3A InputDetail |
bind:change | \u8F93\u5165\u5185\u5BB9\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u8F93\u5165\u503C; \u5728 extra-event-params \u4E3A true \u65F6\u4E3A InputDetail |
bind:confirm | \u70B9\u51FB\u5B8C\u6210\u6309\u94AE\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u8F93\u5165\u503C |
bind:click-icon | \u70B9\u51FB\u5C3E\u90E8\u56FE\u6807\u65F6\u89E6\u53D1 | - |
bind:focus | \u8F93\u5165\u6846\u805A\u7126\u65F6\u89E6\u53D1 | event.detail.value: \u5F53\u524D\u8F93\u5165\u503C; event.detail.height: \u952E\u76D8\u9AD8\u5EA6 |
bind:blur | \u8F93\u5165\u6846\u5931\u7126\u65F6\u89E6\u53D1 | event.detail.value: \u5F53\u524D\u8F93\u5165\u503C; event.detail.cursor: \u6E38\u6807\u4F4D\u7F6E(\u5982\u679C type \u4E0D\u4E3A textarea \uFF0C\u503C\u4E3A 0 ) |
bind:clear | \u70B9\u51FB\u6E05\u7A7A\u63A7\u4EF6\u65F6\u89E6\u53D1 | - |
bind:click-input | \u70B9\u51FB\u8F93\u5165\u533A\u57DF\u65F6\u89E6\u53D1 | - |
bind:linechange | \u8F93\u5165\u6846\u884C\u6570\u53D8\u5316\u65F6\u8C03\u7528\uFF0C\u53EA\u5BF9 textarea \u6709\u6548 | event.detail = { height: 0, heightRpx: 0, lineCount: 0 } |
bind:keyboardheightchange | \u952E\u76D8\u9AD8\u5EA6\u53D1\u751F\u53D8\u5316\u7684\u65F6\u5019\u89E6\u53D1\u6B64\u4E8B\u4EF6 | event.detail = { height: height, duration: duration } |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u8F93\u5165\u503C | string | - |
cursor | \u5149\u6807\u4F4D\u7F6E | number | - |
keyCode | \u952E\u503C | number | - |
callback | \u8C03\u7528\u8BE5\u51FD\u6570\u4F20 { value: string, cursor: number } \u6765\u66FF\u6362\u8F93\u5165\u6846\u7684\u5185\u5BB9\uFF0C\u5177\u4F53\u7528\u6CD5\u53EF\u4EE5\u53C2\u8003 wx-input | function | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
label | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u6807\u7B7E\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86label \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
left-icon | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u5934\u90E8\u56FE\u6807 |
right-icon | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u5C3E\u90E8\u56FE\u6807 |
button | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u5C3E\u90E8\u6309\u94AE |
input | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\uFF0C\u4F7F\u7528\u6B64\u63D2\u69FD\u540E\uFF0C\u4E0E\u8F93\u5165\u6846\u76F8\u5173\u7684\u5C5E\u6027\u548C\u4E8B\u4EF6\u5C06\u5931\u6548 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class v1.10.21 | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
label-class | \u5DE6\u4FA7\u6587\u672C\u6837\u5F0F\u7C7B |
input-class | \u8F93\u5165\u6846\u6837\u5F0F\u7C7B |
right-icon-class | \u53F3\u4FA7\u56FE\u6807\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u4E3A\u5546\u54C1\u76F8\u5173\u64CD\u4F5C\u63D0\u4F9B\u4FBF\u6377\u4EA4\u4E92\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-goods-action": "@vant/weapp/goods-action/index",
- "van-goods-action-icon": "@vant/weapp/goods-action-icon/index",
- "van-goods-action-button": "@vant/weapp/goods-action-button/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
<van-goods-action>
- <van-goods-action-icon icon="chat-o" text="\u5BA2\u670D" bind:click="onClickIcon" />
- <van-goods-action-icon icon="cart-o" text="\u8D2D\u7269\u8F66" bind:click="onClickIcon" />
- <van-goods-action-button
- text="\u52A0\u5165\u8D2D\u7269\u8F66"
- type="warning"
- bind:click="onClickButton"
- />
- <van-goods-action-button text="\u7ACB\u5373\u8D2D\u4E70" bind:click="onClickButton" />
-</van-goods-action>
-
Page({
- onClickIcon() {
- Toast('\u70B9\u51FB\u56FE\u6807');
- },
-
- onClickButton() {
- Toast('\u70B9\u51FB\u6309\u94AE');
- },
-});
-
\u8BBE\u7F6Edot
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\u3002\u8BBE\u7F6Einfo
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002
<van-goods-action>
- <van-goods-action-icon icon="chat-o" text="\u5BA2\u670D" dot />
- <van-goods-action-icon icon="cart-o" text="\u8D2D\u7269\u8F66" info="5" />
- <van-goods-action-icon icon="shop-o" text="\u5E97\u94FA" />
- <van-goods-action-button text="\u52A0\u5165\u8D2D\u7269\u8F66" type="warning" />
- <van-goods-action-button text="\u7ACB\u5373\u8D2D\u4E70" />
-</van-goods-action>
-
\u901A\u8FC7color
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u6309\u94AE\u7684\u989C\u8272\uFF0C\u652F\u6301\u4F20\u5165linear-gradient
\u6E10\u53D8\u8272\u3002
<van-goods-action>
- <van-goods-action-icon icon="chat-o" text="\u5BA2\u670D" />
- <van-goods-action-icon icon="cart-o" text="\u8D2D\u7269\u8F66" info="5" />
- <van-goods-action-icon icon="shop-o" text="\u5E97\u94FA" />
- <van-goods-action-button color="#be99ff" text="\u52A0\u5165\u8D2D\u7269\u8F66" type="warning" />
- <van-goods-action-button color="#7232dd" text="\u7ACB\u5373\u8D2D\u4E70" />
-</van-goods-action>
-
\u901A\u8FC7plain
\u5C5E\u6027\u5C06\u6309\u94AE\u8BBE\u7F6E\u4E3A\u6734\u7D20\u6309\u94AE\uFF0C\u6734\u7D20\u6309\u94AE\u7684\u6587\u5B57\u4E3A\u6309\u94AE\u989C\u8272\uFF0C\u80CC\u666F\u4E3A\u767D\u8272\u3002
<van-goods-action>
- <van-goods-action-icon icon="chat-o" text="\u5BA2\u670D" />
- <van-goods-action-icon icon="cart-o" text="\u8D2D\u7269\u8F66" info="5" />
- <van-goods-action-icon icon="shop-o" text="\u5E97\u94FA" />
- <van-goods-action-button color="#7232dd" text="\u52A0\u5165\u8D2D\u7269" type="warning" />
- <van-goods-action-button plain color="#7232dd" text="\u7ACB\u5373\u8D2D\u4E70" />
-</van-goods-action>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
safe-area-inset-bottom | \u662F\u5426\u4E3A iPhoneX \u7559\u51FA\u5E95\u90E8\u5B89\u5168\u8DDD\u79BB | boolean | true |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
text | \u6309\u94AE\u6587\u5B57 | string | - |
icon | \u56FE\u6807\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u89C1icon \u7EC4\u4EF6 | string | - |
info | \u56FE\u6807\u53F3\u4E0A\u89D2\u63D0\u793A\u4FE1\u606F | string | number | - |
color v1.10.15 | \u56FE\u6807\u989C\u8272 | string | inherit |
size | \u56FE\u6807\u5927\u5C0F\uFF0C\u5982 20px\uFF0C2em\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | - |
url | \u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740 | string | - |
link-type | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo switchTab reLaunch | string | navigateTo |
id | \u6807\u8BC6\u7B26 | string | - |
disabled | \u662F\u5426\u7981\u7528\u6309\u94AE | boolean | false |
loading | \u662F\u5426\u663E\u793A\u4E3A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
open-type | \u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
app-parameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570 | string | - |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0C zh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en |
session-from | \u4F1A\u8BDD\u6765\u6E90 | string | - |
send-message-title | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898 | string | \u5F53\u524D\u6807\u9898 |
send-message-path | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 |
send-message-img | sendMessageImg | string | \u622A\u56FE |
show-message-card | \u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247 | string | false |
class-prefix v1.10.1 | \u7C7B\u540D\u524D\u7F00 | string | van-icon |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
text | \u6309\u94AE\u6587\u5B57 | string | - |
color | \u6309\u94AE\u989C\u8272\uFF0C\u652F\u6301\u4F20\u5165 linear-gradient \u6E10\u53D8\u8272 | string | - |
url | \u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740 | string | - |
link-type | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo switchTab reLaunch | string | navigateTo |
id | \u6807\u8BC6\u7B26 | string | - |
type | \u6309\u94AE\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary warning danger | string | danger |
plain | \u662F\u5426\u4E3A\u6734\u7D20\u6309\u94AE | boolean | false |
size | \u6309\u94AE\u5C3A\u5BF8\uFF0C\u53EF\u9009\u503C\u4E3A normal large small mini | string | normal |
disabled | \u662F\u5426\u7981\u7528\u6309\u94AE | boolean | false |
loading | \u662F\u5426\u663E\u793A\u4E3A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
open-type | \u5FAE\u4FE1\u5F00\u653E\u80FD\u529B\uFF0C\u5177\u4F53\u652F\u6301\u53EF\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 | string | - |
app-parameter | \u6253\u5F00 APP \u65F6\uFF0C\u5411 APP \u4F20\u9012\u7684\u53C2\u6570 | string | - |
lang | \u6307\u5B9A\u8FD4\u56DE\u7528\u6237\u4FE1\u606F\u7684\u8BED\u8A00\uFF0Czh_CN \u7B80\u4F53\u4E2D\u6587\uFF0C zh_TW \u7E41\u4F53\u4E2D\u6587\uFF0Cen \u82F1\u6587 | string | en |
session-from | \u4F1A\u8BDD\u6765\u6E90 | string | - |
send-message-title | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u6807\u9898 | string | \u5F53\u524D\u6807\u9898 |
send-message-path | \u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247\u70B9\u51FB\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F\u8DEF\u5F84 | string | \u5F53\u524D\u5206\u4EAB\u8DEF\u5F84 |
send-message-img | sendMessageImg | string | \u622A\u56FE |
show-message-card | \u663E\u793A\u4F1A\u8BDD\u5185\u6D88\u606F\u5361\u7247 | string | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6\u56DE\u8C03 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
icon | \u81EA\u5B9A\u4E49\u56FE\u6807 |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u6309\u94AE\u663E\u793A\u5185\u5BB9 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
icon-class | \u56FE\u6807\u6837\u5F0F\u7C7B |
text-class | \u6587\u5B57\u6837\u5F0F\u7C7B |
info-class v1.10.20 | \u56FE\u6807\u53F3\u4E0A\u89D2\u6587\u5B57\u6837\u5F0F\u7C7B |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u5BAB\u683C\u53EF\u4EE5\u5728\u6C34\u5E73\u65B9\u5411\u4E0A\u628A\u9875\u9762\u5206\u9694\u6210\u7B49\u5BBD\u5EA6\u7684\u533A\u5757\uFF0C\u7528\u4E8E\u5C55\u793A\u5185\u5BB9\u6216\u8FDB\u884C\u9875\u9762\u5BFC\u822A\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-grid": "@vant/weapp/grid/index",
- "van-grid-item": "@vant/weapp/grid-item/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u901A\u8FC7icon
\u5C5E\u6027\u8BBE\u7F6E\u683C\u5B50\u5185\u7684\u56FE\u6807\uFF0Ctext
\u5C5E\u6027\u8BBE\u7F6E\u6587\u5B57\u5185\u5BB9\u3002
<van-grid>
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
-</van-grid>
-
\u9ED8\u8BA4\u4E00\u884C\u5C55\u793A\u56DB\u4E2A\u683C\u5B50\uFF0C\u53EF\u4EE5\u901A\u8FC7column-num
\u81EA\u5B9A\u4E49\u5217\u6570\u3002
<van-grid column-num="3">
- <van-grid-item icon="photo-o" text="\u6587\u5B57" wx:for="{{ 6 }}" />
-</van-grid>
-
\u901A\u8FC7\u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u683C\u5B50\u5C55\u793A\u7684\u5185\u5BB9\u3002
<van-grid column-num="3" border="{{ false }}">
- <van-grid-item use-slot wx:for="{{ 3 }}" wx:for-item="index">
- <image
- style="width: 100%; height: 90px;"
- src="https://img.yzcdn.cn/vant/apple-{{ index + 1 }}.jpg"
- />
- </van-grid-item>
-</van-grid>
-
\u8BBE\u7F6Esquare
\u5C5E\u6027\u540E\uFF0C\u683C\u5B50\u7684\u9AD8\u5EA6\u4F1A\u548C\u5BBD\u5EA6\u4FDD\u6301\u4E00\u81F4\u3002
<van-grid square>
- <van-grid-item icon="photo-o" text="\u6587\u5B57" wx:for="{{ 8 }}" />
-</van-grid>
-
\u901A\u8FC7gutter
\u5C5E\u6027\u8BBE\u7F6E\u683C\u5B50\u4E4B\u95F4\u7684\u8DDD\u79BB\u3002
<van-grid gutter="{{ 10 }}">
- <van-grid-item icon="photo-o" text="\u6587\u5B57" wx:for="{{ 8 }}" />
-</van-grid>
-
\u5C06direction
\u5C5E\u6027\u8BBE\u7F6E\u4E3Ahorizontal
\uFF0C\u53EF\u4EE5\u8BA9\u5BAB\u683C\u7684\u5185\u5BB9\u5448\u6A2A\u5411\u6392\u5217\u3002
<van-grid direction="horizontal" column-num="2">
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
- <van-grid-item icon="photo-o" text="\u6587\u5B57" />
-</van-grid>
-
\u53EF\u4EE5\u901A\u8FC7url
\u5C5E\u6027\u8FDB\u884C\u9875\u9762\u8DF3\u8F6C\uFF0C\u901A\u8FC7link-type
\u5C5E\u6027\u63A7\u5236\u8DF3\u8F6C\u7C7B\u578B\u3002
<van-grid clickable column-num="2">
- <van-grid-item
- icon="home-o"
- link-type="navigateTo"
- url="/pages/dashboard/index"
- text="Navigate \u8DF3\u8F6C"
- />
- <van-grid-item
- icon="search"
- link-type="reLaunch"
- url="/pages/dashboard/index"
- text="ReLaunch \u8DF3\u8F6C"
- />
-</van-grid>
-
\u8BBE\u7F6Edot
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\u3002\u8BBE\u7F6Ebadge
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002
<van-grid column-num="2">
- <van-grid-item icon="home-o" text="\u6587\u5B57" dot />
- <van-grid-item icon="search" text="\u6587\u5B57" badge="99+" />
-</van-grid>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
column-num | \u5217\u6570 | number | 4 |
icon-size v1.3.2 | \u56FE\u6807\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | 28px |
gutter | \u683C\u5B50\u4E4B\u95F4\u7684\u95F4\u8DDD\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 0 |
border | \u662F\u5426\u663E\u793A\u8FB9\u6846 | boolean | true |
center | \u662F\u5426\u5C06\u683C\u5B50\u5185\u5BB9\u5C45\u4E2D\u663E\u793A | boolean | true |
square | \u662F\u5426\u5C06\u683C\u5B50\u56FA\u5B9A\u4E3A\u6B63\u65B9\u5F62 | boolean | false |
clickable | \u662F\u5426\u5F00\u542F\u683C\u5B50\u70B9\u51FB\u53CD\u9988 | boolean | false |
direction | \u683C\u5B50\u5185\u5BB9\u6392\u5217\u7684\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A horizontal | string | vertical |
reverse v1.7.0 | \u662F\u5426\u8C03\u6362\u56FE\u6807\u548C\u6587\u672C\u7684\u4F4D\u7F6E | boolean | false |
use-slot | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u5185\u5BB9\u7684\u63D2\u69FD | boolean | false |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
text | \u6587\u5B57 | string | - |
icon | \u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
icon-color | \u56FE\u6807\u989C\u8272 | string | - |
icon-prefix v1.7.0 | \u7B2C\u4E09\u65B9\u56FE\u6807\u524D\u7F00 | string | van-icon |
dot | \u662F\u5426\u663E\u793A\u56FE\u6807\u53F3\u4E0A\u89D2\u5C0F\u7EA2\u70B9 | boolean | false |
badge | \u56FE\u6807\u53F3\u4E0A\u89D2\u5FBD\u6807\u7684\u5185\u5BB9 | string | number | - |
url | \u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740 | string | - |
link-type | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo switchTab reLaunch | string | navigateTo |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u683C\u5B50\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u5BAB\u683C\u7684\u6240\u6709\u5185\u5BB9\uFF0C\u9700\u8981\u8BBE\u7F6Euse-slot \u5C5E\u6027 |
icon | \u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86use-slot \u6216\u8005icon \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
text | \u81EA\u5B9A\u4E49\u6587\u5B57\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86use-slot \u6216\u8005text \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
content-class | \u5185\u5BB9\u6837\u5F0F\u7C7B |
icon-class | \u56FE\u6807\u6837\u5F0F\u7C7B |
text-class | \u6587\u672C\u6837\u5F0F\u7C7B |
\u57FA\u4E8E\u5B57\u4F53\u7684\u56FE\u6807\u96C6\uFF0C\u53EF\u4EE5\u901A\u8FC7 Icon \u7EC4\u4EF6\u4F7F\u7528\uFF0C\u4E5F\u53EF\u4EE5\u5728\u5176\u4ED6\u7EC4\u4EF6\u4E2D\u901A\u8FC7 icon \u5C5E\u6027\u5F15\u7528\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-icon": "@vant/weapp/icon/index"
-}
-
Icon
\u7684name
\u5C5E\u6027\u652F\u6301\u4F20\u5165\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\u3002
<van-icon name="close" />
-<van-icon name="https://b.yzcdn.cn/vant/icon-demo-1126.png" />
-
\u8BBE\u7F6Edot
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\u3002\u8BBE\u7F6Einfo
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002
<van-icon name="chat" dot />
-<van-icon name="chat" info="9" />
-<van-icon name="chat" info="99+" />
-
\u8BBE\u7F6Ecolor
\u5C5E\u6027\u6765\u63A7\u5236\u56FE\u6807\u989C\u8272\u3002
<van-icon name="chat" color="red" />
-
\u8BBE\u7F6Esize
\u5C5E\u6027\u6765\u63A7\u5236\u56FE\u6807\u5927\u5C0F\u3002
<van-icon name="chat" size="50px" />
-
\u5982\u679C\u9700\u8981\u5728\u73B0\u6709 Icon \u7684\u57FA\u7840\u4E0A\u4F7F\u7528\u66F4\u591A\u56FE\u6807\uFF0C\u53EF\u4EE5\u5F15\u5165\u7B2C\u4E09\u65B9 iconfont \u5BF9\u5E94\u7684\u5B57\u4F53\u6587\u4EF6\u548C CSS \u6587\u4EF6\uFF0C\u4E4B\u540E\u5C31\u53EF\u4EE5\u5728 Icon \u7EC4\u4EF6\u4E2D\u76F4\u63A5\u4F7F\u7528\u3002\u4F8B\u5982\uFF0C\u53EF\u4EE5\u5728 app.wxss
\u6587\u4EF6\u4E2D\u5F15\u5165\u3002
/* \u5F15\u5165\u7B2C\u4E09\u65B9\u6216\u81EA\u5B9A\u4E49\u7684\u5B57\u4F53\u56FE\u6807\u6837\u5F0F */
-@font-face {
- font-family: 'my-icon';
- src: url('./my-icon.ttf') format('truetype');
-}
-
-.my-icon {
- font-family: 'my-icon';
-}
-
-.my-icon-extra::before {
- content: '\\e626';
-}
-
<!-- \u901A\u8FC7 class-prefix \u6307\u5B9A\u7C7B\u540D\u4E3A my-icon -->
-<van-icon class-prefix="my-icon" name="extra" />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5 | string | - |
dot | \u662F\u5426\u663E\u793A\u56FE\u6807\u53F3\u4E0A\u89D2\u5C0F\u7EA2\u70B9 | boolean | false |
info | \u56FE\u6807\u53F3\u4E0A\u89D2\u6587\u5B57\u63D0\u793A | string | number | - |
color | \u56FE\u6807\u989C\u8272 | string | inherit |
size v1.10.20 | \u56FE\u6807\u5927\u5C0F\uFF0C\u5982 20px \uFF0C2em \uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | inherit |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
class-prefix | \u7C7B\u540D\u524D\u7F00 | string | van-icon |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u56FE\u6807\u65F6\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
info-class | \u56FE\u6807\u53F3\u4E0A\u89D2\u6587\u5B57\u6837\u5F0F\u7C7B |
\u8FD9\u4E2A\u662F\u5F00\u53D1\u8005\u5DE5\u5177\u672C\u8EAB\u7684\u95EE\u9898\uFF0C\u53EF\u4EE5\u5FFD\u7565\uFF0C\u5177\u4F53\u53EF\u4EE5\u67E5\u770B\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6587\u6863 - \u6CE8\u610F\u4E8B\u9879\u7B2C 5 \u6761\u3002
\u589E\u5F3A\u7248\u7684 img \u6807\u7B7E\uFF0C\u63D0\u4F9B\u591A\u79CD\u56FE\u7247\u586B\u5145\u6A21\u5F0F\uFF0C\u652F\u6301\u56FE\u7247\u61D2\u52A0\u8F7D\u3001\u52A0\u8F7D\u4E2D\u63D0\u793A\u3001\u52A0\u8F7D\u5931\u8D25\u63D0\u793A\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-image": "@vant/weapp/image/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
\u57FA\u7840\u7528\u6CD5\u4E0E\u539F\u751F image \u6807\u7B7E\u4E00\u81F4\uFF0C\u53EF\u4EE5\u8BBE\u7F6Esrc
\u3001width
\u3001height
\u7B49\u539F\u751F\u5C5E\u6027\u3002
<van-image width="100" height="100" src="https://img.yzcdn.cn/vant/cat.jpeg" />
-
\u901A\u8FC7fit
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u56FE\u7247\u586B\u5145\u6A21\u5F0F\uFF0C\u53EF\u9009\u503C\u89C1\u4E0B\u65B9\u8868\u683C\u3002
<van-image
- width="10rem"
- height="10rem"
- fit="contain"
- src="https://img.yzcdn.cn/vant/cat.jpeg"
-/>
-
\u901A\u8FC7round
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u56FE\u7247\u53D8\u5706\uFF0C\u6CE8\u610F\u5F53\u56FE\u7247\u5BBD\u9AD8\u4E0D\u76F8\u7B49\u4E14fit
\u4E3Acontain
\u6216scale-down
\u65F6\uFF0C\u5C06\u65E0\u6CD5\u586B\u5145\u4E00\u4E2A\u5B8C\u6574\u7684\u5706\u5F62\u3002
<van-image
- round
- width="10rem"
- height="10rem"
- src="https://img.yzcdn.cn/vant/cat.jpeg"
-/>
-
\u56FE\u7247\u61D2\u52A0\u8F7D\uFF0C\u5728\u5373\u5C06\u8FDB\u5165\u4E00\u5B9A\u8303\u56F4\uFF08\u4E0A\u4E0B\u4E09\u5C4F\uFF09\u65F6\u624D\u5F00\u59CB\u52A0\u8F7D\u3002
<van-image
- width="100"
- height="100"
- lazy-load
- src="https://img.yzcdn.cn/vant/cat.jpeg"
-/>
-
Image
\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u9ED8\u8BA4\u7684\u52A0\u8F7D\u4E2D\u63D0\u793A\uFF0C\u652F\u6301\u901A\u8FC7loading
\u63D2\u69FD\u81EA\u5B9A\u4E49\u5185\u5BB9\u3002
<van-image use-loading-slot>
- <van-loading slot="loading" type="spinner" size="20" vertical />
-</van-image>
-
Image
\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u9ED8\u8BA4\u7684\u52A0\u8F7D\u5931\u8D25\u63D0\u793A\uFF0C\u652F\u6301\u901A\u8FC7error
\u63D2\u69FD\u81EA\u5B9A\u4E49\u5185\u5BB9\u3002
<van-image use-error-slot>
- <text slot="error">\u52A0\u8F7D\u5931\u8D25</text>
-</van-image>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
src | \u56FE\u7247\u94FE\u63A5 | string | - |
fit | \u56FE\u7247\u586B\u5145\u6A21\u5F0F | string | fill |
alt | \u66FF\u4EE3\u6587\u672C | string | - |
width | \u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | - |
height | \u9AD8\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | - |
radius | \u5706\u89D2\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 0 |
round | \u662F\u5426\u663E\u793A\u4E3A\u5706\u5F62 | boolean | false |
lazy-load | \u662F\u5426\u61D2\u52A0\u8F7D | boolean | false |
webp v1.10.11 | \u662F\u5426\u89E3\u6790 webp \u683C\u5F0F | boolean | false |
show-error | \u662F\u5426\u5C55\u793A\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\u63D0\u793A | boolean | true |
show-loading | \u662F\u5426\u5C55\u793A\u56FE\u7247\u52A0\u8F7D\u4E2D\u63D0\u793A | boolean | true |
use-error-slot | \u662F\u5426\u4F7F\u7528 error \u63D2\u69FD | boolean | false |
use-loading-slot | \u662F\u5426\u4F7F\u7528 loading \u63D2\u69FD | boolean | false |
show-menu-by-longpress | \u662F\u5426\u5F00\u542F\u957F\u6309\u56FE\u7247\u663E\u793A\u8BC6\u522B\u5C0F\u7A0B\u5E8F\u7801\u83DC\u5355 | boolean | false |
\u540D\u79F0 | \u542B\u4E49 |
---|---|
contain | \u4FDD\u6301\u5BBD\u9AD8\u7F29\u653E\u56FE\u7247\uFF0C\u4F7F\u56FE\u7247\u7684\u957F\u8FB9\u80FD\u5B8C\u5168\u663E\u793A\u51FA\u6765 |
cover | \u4FDD\u6301\u5BBD\u9AD8\u7F29\u653E\u56FE\u7247\uFF0C\u4F7F\u56FE\u7247\u7684\u77ED\u8FB9\u80FD\u5B8C\u5168\u663E\u793A\u51FA\u6765\uFF0C\u88C1\u526A\u957F\u8FB9 |
fill | \u62C9\u4F38\u56FE\u7247\uFF0C\u4F7F\u56FE\u7247\u586B\u6EE1\u5143\u7D20 |
widthFix | \u7F29\u653E\u6A21\u5F0F\uFF0C\u5BBD\u5EA6\u4E0D\u53D8\uFF0C\u9AD8\u5EA6\u81EA\u52A8\u53D8\u5316\uFF0C\u4FDD\u6301\u539F\u56FE\u5BBD\u9AD8\u6BD4\u4E0D\u53D8 |
heightFix | \u7F29\u653E\u6A21\u5F0F\uFF0C\u9AD8\u5EA6\u4E0D\u53D8\uFF0C\u5BBD\u5EA6\u81EA\u52A8\u53D8\u5316\uFF0C\u4FDD\u6301\u539F\u56FE\u5BBD\u9AD8\u6BD4\u4E0D\u53D8 |
none | \u4FDD\u6301\u56FE\u7247\u539F\u6709\u5C3A\u5BF8 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u56FE\u7247\u65F6\u89E6\u53D1 | event: Event |
bind:load | \u56FE\u7247\u52A0\u8F7D\u5B8C\u6BD5\u65F6\u89E6\u53D1 | event: Event |
bind:error | \u56FE\u7247\u52A0\u8F7D\u5931\u8D25\u65F6\u89E6\u53D1 | event: Event |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
loading | \u81EA\u5B9A\u4E49\u52A0\u8F7D\u4E2D\u7684\u63D0\u793A\u5185\u5BB9 |
error | \u81EA\u5B9A\u4E49\u52A0\u8F7D\u5931\u8D25\u65F6\u7684\u63D0\u793A\u5185\u5BB9 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
image-class | \u56FE\u7247\u6837\u5F0F\u7C7B |
loading-class | loading \u6837\u5F0F\u7C7B |
error-class | error \u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5217\u8868\u7684\u7D22\u5F15\u5206\u7C7B\u663E\u793A\u548C\u5FEB\u901F\u5B9A\u4F4D\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-index-bar": "@vant/weapp/index-bar/index",
- "van-index-anchor": "@vant/weapp/index-anchor/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u70B9\u51FB\u7D22\u5F15\u680F\u65F6\uFF0C\u4F1A\u81EA\u52A8\u8DF3\u8F6C\u5230\u5BF9\u5E94\u7684IndexAnchor
\u951A\u70B9\u4F4D\u7F6E\u3002
<van-index-bar>
- <view>
- <van-index-anchor index="A" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- </view>
-
- <view>
- <van-index-anchor index="B" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- </view>
-
- ...
-</van-index-bar>
-
\u53EF\u4EE5\u901A\u8FC7index-list
\u5C5E\u6027\u81EA\u5B9A\u4E49\u5C55\u793A\u7684\u7D22\u5F15\u5B57\u7B26\u5217\u8868\u3002
<van-index-bar index-list="{{ indexList }}">
- <view>
- <van-index-anchor index="1">\u6807\u98981</van-index-anchor>
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- </view>
-
- <view>
- <van-index-anchor index="2">\u6807\u98982</van-index-anchor>
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- <van-cell title="\u6587\u672C" />
- </view>
-
- ...
-</van-index-bar>
-
Page({
- data: {
- indexList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C | \u7248\u672C |
---|---|---|---|---|
index-list | \u7D22\u5F15\u5B57\u7B26\u5217\u8868 | string[] | number[] | A-Z | - |
z-index | z-index \u5C42\u7EA7 | number | 1 | - |
sticky | \u662F\u5426\u5F00\u542F\u951A\u70B9\u81EA\u52A8\u5438\u9876 | boolean | true | - |
sticky-offset-top | \u951A\u70B9\u81EA\u52A8\u5438\u9876\u65F6\u4E0E\u9876\u90E8\u7684\u8DDD\u79BB | number | 0 | - |
highlight-color | \u7D22\u5F15\u5B57\u7B26\u9AD8\u4EAE\u989C\u8272 | string | #07c160 | - |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C | \u7248\u672C |
---|---|---|---|---|
use-slot | \u662F\u5426\u4F7F\u7528\u81EA\u5B9A\u4E49\u5185\u5BB9\u7684\u63D2\u69FD | boolean | false | - |
index | \u7D22\u5F15\u5B57\u7B26 | string | number | - | - |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
select | \u9009\u4E2D\u5B57\u7B26\u65F6\u89E6\u53D1 | index: \u7D22\u5F15\u5B57\u7B26 |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u951A\u70B9\u4F4D\u7F6E\u663E\u793A\u5185\u5BB9\uFF0C\u9ED8\u8BA4\u4E3A\u7D22\u5F15\u5B57\u7B26 |
\u7531\u4E8E <IndexBar />
\u5185\u90E8\u4F7F\u7528 wx.pageScrollTo \u6EDA\u52A8\u5230\u6307\u5B9A\u4F4D\u7F6E\uFF0C\u56E0\u6B64\u53EA\u652F\u6301\u9875\u9762\u7EA7\u6EDA\u52A8\uFF0C\u65E0\u6CD5\u5728\u6EDA\u52A8\u5143\u7D20\u4E2D\u5D4C\u5957\u4F7F\u7528\uFF0C\u4F8B\u5982\uFF1Aview
\u4F7F\u7528 overflow: scroll;
\u6216\u8005 scroll-view
\uFF0C\u5177\u4F53\u53EF\u67E5\u770B\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u6587\u6863\u3002\u5386\u53F2 issue: #4252
\u52A0\u8F7D\u56FE\u6807\uFF0C\u7528\u4E8E\u8868\u793A\u52A0\u8F7D\u4E2D\u7684\u8FC7\u6E21\u72B6\u6001\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-loading": "@vant/weapp/loading/index"
-}
-
<van-loading /> <van-loading type="spinner" />
-
<van-loading color="#1989fa" /> <van-loading type="spinner" color="#1989fa" />
-
<van-loading size="24px">\u52A0\u8F7D\u4E2D...</van-loading>
-
<van-loading size="24px" vertical>\u52A0\u8F7D\u4E2D...</van-loading>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
color | \u989C\u8272 | string | #c9c9c9 |
type | \u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A spinner | string | circular |
size | \u52A0\u8F7D\u56FE\u6807\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | string | number | 30px |
text-size v1.0.0 | \u6587\u5B57\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A\u4E3A px | string | number | 14px |
vertical v1.0.0 | \u662F\u5426\u5782\u76F4\u6392\u5217\u56FE\u6807\u548C\u6587\u5B57\u5185\u5BB9 | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u52A0\u8F7D\u6587\u6848 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u4E3A\u9875\u9762\u63D0\u4F9B\u5BFC\u822A\u529F\u80FD\uFF0C\u5E38\u7528\u4E8E\u9875\u9762\u9876\u90E8\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-nav-bar": "@vant/weapp/nav-bar/index"
-}
-
<van-nav-bar
- title="\u6807\u9898"
- left-text="\u8FD4\u56DE"
- right-text="\u6309\u94AE"
- left-arrow
- bind:click-left="onClickLeft"
- bind:click-right="onClickRight"
-/>
-
Page({
- onClickLeft() {
- wx.showToast({ title: '\u70B9\u51FB\u8FD4\u56DE', icon: 'none' });
- },
- onClickRight() {
- wx.showToast({ title: '\u70B9\u51FB\u6309\u94AE', icon: 'none' });
- },
-});
-
\u901A\u8FC7 slot \u5B9A\u5236\u5185\u5BB9\u3002
<van-nav-bar title="\u6807\u9898" left-text="\u8FD4\u56DE" left-arrow>
- <van-icon name="search" slot="right" />
-</van-nav-bar>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u6807\u9898 | string | '' |
left-text | \u5DE6\u4FA7\u6587\u6848 | string | '' |
right-text | \u53F3\u4FA7\u6587\u6848 | string | '' |
left-arrow | \u662F\u5426\u663E\u793A\u5DE6\u4FA7\u7BAD\u5934 | boolean | false |
fixed | \u662F\u5426\u56FA\u5B9A\u5728\u9876\u90E8 | boolean | false |
placeholder | \u56FA\u5B9A\u5728\u9876\u90E8\u65F6\u662F\u5426\u5F00\u542F\u5360\u4F4D | boolean | false |
border | \u662F\u5426\u663E\u793A\u4E0B\u8FB9\u6846 | boolean | true |
z-index | \u5143\u7D20 z-index | number | 1 |
custom-style | \u6839\u8282\u70B9\u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
safe-area-inset-top | \u662F\u5426\u7559\u51FA\u9876\u90E8\u5B89\u5168\u8DDD\u79BB\uFF08\u72B6\u6001\u680F\u9AD8\u5EA6\uFF09 | boolean | true |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49\u6807\u9898 |
left | \u81EA\u5B9A\u4E49\u5DE6\u4FA7\u533A\u57DF\u5185\u5BB9 |
right | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u533A\u57DF\u5185\u5BB9 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click-left | \u70B9\u51FB\u5DE6\u4FA7\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:click-right | \u70B9\u51FB\u53F3\u4FA7\u6309\u94AE\u65F6\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
title-class | \u6807\u9898\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5FAA\u73AF\u64AD\u653E\u5C55\u793A\u4E00\u7EC4\u6D88\u606F\u901A\u77E5\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-notice-bar": "@vant/weapp/notice-bar/index"
-}
-
<van-notice-bar
- left-icon="volume-o"
- text="\u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002"
-/>
-
\u901A\u77E5\u680F\u7684\u5185\u5BB9\u957F\u5EA6\u6EA2\u51FA\u65F6\u4F1A\u81EA\u52A8\u5F00\u542F\u6EDA\u52A8\u64AD\u653E\uFF0C\u901A\u8FC7 scrollable
\u5C5E\u6027\u53EF\u4EE5\u63A7\u5236\u8BE5\u884C\u4E3A\u3002
<!-- \u6587\u5B57\u8F83\u77ED\u65F6\uFF0C\u901A\u8FC7\u8BBE\u7F6E scrollable \u5C5E\u6027\u5F00\u542F\u6EDA\u52A8\u64AD\u653E -->
-<van-notice-bar scrollable text="\u6280\u672F\u662F\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002" />
-
-<!-- \u6587\u5B57\u8F83\u957F\u65F6\uFF0C\u901A\u8FC7\u7981\u7528 scrollable \u5C5E\u6027\u5173\u95ED\u6EDA\u52A8\u64AD\u653E -->
-<van-notice-bar
- scrollable="{{ false }}"
- text="\u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002"
-/>
-
\u6587\u5B57\u8F83\u957F\u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7\u8BBE\u7F6E wrapable
\u5C5E\u6027\u6765\u5F00\u542F\u591A\u884C\u5C55\u793A\u3002
<van-notice-bar
- wrapable
- scrollable="{{ false }}"
- text="\u5728\u4EE3\u7801\u9605\u8BFB\u8FC7\u7A0B\u4E2D\u4EBA\u4EEC\u8BF4\u810F\u8BDD\u7684\u9891\u7387\u662F\u8861\u91CF\u4EE3\u7801\u8D28\u91CF\u7684\u552F\u4E00\u6807\u51C6\u3002"
-/>
-
\u901A\u77E5\u680F\u652F\u6301 closeable
\u548C link
\u4E24\u79CD\u6A21\u5F0F\u3002
<!-- closeable \u6A21\u5F0F\uFF0C\u5728\u53F3\u4FA7\u663E\u793A\u5173\u95ED\u6309\u94AE -->
-<van-notice-bar mode="closeable" text="\u6280\u672F\u662F\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002" />
-
-<!-- link \u6A21\u5F0F\uFF0C\u5728\u53F3\u4FA7\u663E\u793A\u94FE\u63A5\u7BAD\u5934 -->
-<van-notice-bar mode="link" text="\u6280\u672F\u662F\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002" />
-
\u901A\u8FC7 color
\u5C5E\u6027\u8BBE\u7F6E\u6587\u672C\u989C\u8272\uFF0C\u901A\u8FC7 background
\u5C5E\u6027\u8BBE\u7F6E\u80CC\u666F\u8272\u3002
<van-notice-bar
- color="#1989fa"
- background="#ecf9ff"
- left-icon="info-o"
- text="\u6280\u672F\u662F\u5F00\u53D1\u5B83\u7684\u4EBA\u7684\u5171\u540C\u7075\u9B42\u3002"
-/>
-
\u4F7F\u7528speed
\u5C5E\u6027\u63A7\u5236\u6EDA\u52A8\u901F\u7387\u3002
<van-notice-bar
- text="{{ text }}"
- speed="{{speedValue}}"
- left-icon="//img.yzcdn.cn/public_files/2017/8/10/6af5b7168eed548100d9041f07b7c616.png"
-/>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
mode | \u901A\u77E5\u680F\u6A21\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A closeable link | string | '' |
text | \u901A\u77E5\u6587\u672C\u5185\u5BB9 | string | '' |
color | \u901A\u77E5\u6587\u672C\u989C\u8272 | string | #ed6a0c |
background | \u6EDA\u52A8\u6761\u80CC\u666F | string | #fffbe8 |
left-icon | \u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5 | string | - |
delay | \u52A8\u753B\u5EF6\u8FDF\u65F6\u95F4 (ms) | number | 1 |
speed | \u6EDA\u52A8\u901F\u7387 (px/s) | number | 60 |
scrollable | \u662F\u5426\u5F00\u542F\u6EDA\u52A8\u64AD\u653E\uFF0C\u5185\u5BB9\u957F\u5EA6\u6EA2\u51FA\u65F6\u9ED8\u8BA4\u5F00\u542F | boolean | - |
wrapable | \u662F\u5426\u5F00\u542F\u6587\u672C\u6362\u884C\uFF0C\u53EA\u5728\u7981\u7528\u6EDA\u52A8\u65F6\u751F\u6548 | boolean | false |
open-type | \u5FAE\u4FE1\u5F00\u653E\u80FD\u529B | string | navigate |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u901A\u77E5\u680F\u65F6\u89E6\u53D1 | event: Event |
bind:close | \u5173\u95ED\u901A\u77E5\u680F\u65F6\u89E6\u53D1 | event: Event |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u901A\u77E5\u6587\u672C\u5185\u5BB9\uFF0C\u4EC5\u5728 text \u5C5E\u6027\u4E3A\u7A7A\u65F6\u6709\u6548 |
left-icon | \u81EA\u5B9A\u4E49\u5DE6\u4FA7\u56FE\u6807 |
right-icon | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u56FE\u6807 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002
\u540D\u79F0 | \u9ED8\u8BA4\u503C | \u63CF\u8FF0 |
---|---|---|
--notice-bar-height | 40px | - |
--notice-bar-padding | 0 var(--van-padding-md) | - |
--notice-bar-wrapable-padding | var(--van-padding-xs) var(--van-padding-md) | - |
--notice-bar-text-color | var(--van-orange-dark) | - |
--notice-bar-font-size | var(--van-font-size-md) | - |
--notice-bar-line-height | 24px | - |
--notice-bar-background-color | var(--van-orange-light) | - |
--notice-bar-icon-size | 16px | - |
--notice-bar-icon-min-width | 24px | - |
\u5728\u9875\u9762\u9876\u90E8\u5C55\u793A\u6D88\u606F\u63D0\u793A\uFF0C\u652F\u6301\u51FD\u6570\u8C03\u7528\u548C\u7EC4\u4EF6\u8C03\u7528\u4E24\u79CD\u65B9\u5F0F\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-notify": "@vant/weapp/notify/index"
-}
-
import Notify from '@vant/weapp/notify/notify';
-
-Notify('\u901A\u77E5\u5185\u5BB9');
-
<!-- \u5728\u9875\u9762\u5185\u6DFB\u52A0\u5BF9\u5E94\u7684\u8282\u70B9 -->
-<van-notify id="van-notify" />
-
\u652F\u6301primary
\u3001success
\u3001warning
\u3001danger
\u56DB\u79CD\u901A\u77E5\u7C7B\u578B\uFF0C\u9ED8\u8BA4\u4E3Adanger
\u3002
// \u4E3B\u8981\u901A\u77E5
-Notify({ type: 'primary', message: '\u901A\u77E5\u5185\u5BB9' });
-
-// \u6210\u529F\u901A\u77E5
-Notify({ type: 'success', message: '\u901A\u77E5\u5185\u5BB9' });
-
-// \u5371\u9669\u901A\u77E5
-Notify({ type: 'danger', message: '\u901A\u77E5\u5185\u5BB9' });
-
-// \u8B66\u544A\u901A\u77E5
-Notify({ type: 'warning', message: '\u901A\u77E5\u5185\u5BB9' });
-
\u81EA\u5B9A\u4E49\u6D88\u606F\u901A\u77E5\u7684\u989C\u8272\u548C\u5C55\u793A\u65F6\u957F\u3002
Notify({
- message: '\u81EA\u5B9A\u4E49\u989C\u8272',
- color: '#ad0000',
- background: '#ffe1e1',
-});
-
-Notify({
- message: '\u81EA\u5B9A\u4E49\u65F6\u957F',
- duration: 1000,
-});
-
Notify({
- message: '\u81EA\u5B9A\u4E49\u8282\u70B9\u9009\u62E9\u5668',
- duration: 1000,
- selector: '#custom-selector',
-});
-
<!-- \u5728\u9875\u9762\u5185\u6DFB\u52A0\u81EA\u5B9A\u4E49\u8282\u70B9 -->
-<van-notify id="custom-selector" />
-
\u65B9\u6CD5\u540D | \u8BF4\u660E | \u53C2\u6570 | \u8FD4\u56DE\u503C |
---|---|---|---|
Notify | \u5C55\u793A\u63D0\u793A | options | message | notify \u5B9E\u4F8B |
Notify.clear | \u5173\u95ED\u63D0\u793A | options | void |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
type v1.0.0 | \u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary success warning | string | danger |
message v1.0.0 | \u5C55\u793A\u6587\u6848\uFF0C\u652F\u6301\u901A\u8FC7\\n \u6362\u884C | string | '' |
duration | \u5C55\u793A\u65F6\u957F(ms)\uFF0C\u503C\u4E3A 0 \u65F6\uFF0Cnotify \u4E0D\u4F1A\u6D88\u5931 | number | 3000 |
selector | \u81EA\u5B9A\u4E49\u8282\u70B9\u9009\u62E9\u5668 | string | van-notify |
color | \u5B57\u4F53\u989C\u8272 | string | #fff |
top | \u9876\u90E8\u8DDD\u79BB | number | 0 |
background | \u80CC\u666F\u989C\u8272 | string | - |
context | \u9009\u62E9\u5668\u7684\u9009\u62E9\u8303\u56F4\uFF0C\u53EF\u4EE5\u4F20\u5165\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u7684 this \u4F5C\u4E3A\u4E0A\u4E0B\u6587 | object | \u5F53\u524D\u9875\u9762 |
onClick | \u70B9\u51FB\u65F6\u7684\u56DE\u8C03\u51FD\u6570 | Function | - |
onOpened | \u5B8C\u5168\u5C55\u793A\u540E\u7684\u56DE\u8C03\u51FD\u6570 | Function | - |
onClose | \u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570 | Function | - |
safeAreaInsetTop | \u662F\u5426\u7559\u51FA\u9876\u90E8\u5B89\u5168\u8DDD\u79BB\uFF08\u72B6\u6001\u680F\u9AD8\u5EA6\uFF09 | boolean | false |
\u521B\u5EFA\u4E00\u4E2A\u906E\u7F69\u5C42\uFF0C\u7528\u4E8E\u5F3A\u8C03\u7279\u5B9A\u7684\u9875\u9762\u5143\u7D20\uFF0C\u5E76\u963B\u6B62\u7528\u6237\u8FDB\u884C\u5176\u4ED6\u64CD\u4F5C\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-overlay": "@vant/weapp/overlay/index"
-}
-
<van-button type="primary" bind:click="onClickShow">\u663E\u793A\u906E\u7F69\u5C42</van-button>
-<van-overlay show="{{ show }}" bind:click="onClickHide" />
-
Page({
- data: {
- show: false,
- },
-
- onClickShow() {
- this.setData({ show: true });
- },
-
- onClickHide() {
- this.setData({ show: false });
- },
-});
-
\u901A\u8FC7\u9ED8\u8BA4\u63D2\u69FD\u53EF\u4EE5\u5728\u906E\u7F69\u5C42\u4E0A\u5D4C\u5165\u4EFB\u610F\u5185\u5BB9\u3002
<van-button type="primary" bind:click="onClickShow">\u5D4C\u5165\u5185\u5BB9</van-button>
-<van-overlay show="{{ show }}" bind:click="onClickHide">
- <view class="wrapper">
- <view class="block" catch:tap="noop" />
- </view>
-</van-overlay>
-
Page({
- data: {
- show: false,
- },
-
- onClickShow() {
- this.setData({ show: true });
- },
-
- onClickHide() {
- this.setData({ show: false });
- },
-
- noop() {},
-});
-
.wrapper {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100%;
-}
-
-.block {
- width: 120px;
- height: 120px;
- background-color: #fff;
-}
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u5C55\u793A\u906E\u7F69\u5C42 | boolean | false |
z-index | z-index \u5C42\u7EA7 | string | number | 1 |
duration | \u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u79D2 | string | number | 0.3 |
class-name | \u81EA\u5B9A\u4E49\u7C7B\u540D | string | - |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
lock-scroll v1.7.3 | \u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8\uFF0C\u9501\u5B9A\u65F6\u8499\u5C42\u91CC\u7684\u5185\u5BB9\u4E5F\u5C06\u65E0\u6CD5\u6EDA\u52A8 | boolean | true |
root-portal v1.10.14 | \u662F\u5426\u4ECE\u9875\u9762\u4E2D\u8131\u79BB\u51FA\u6765\uFF0C\u7528\u4E8E\u89E3\u51B3\u5404\u79CD fixed \u5931\u6548\u95EE\u9898\uFF0C\u5FAE\u4FE1\u57FA\u7840\u5E93 >= 2.25.2 | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u9ED8\u8BA4\u63D2\u69FD\uFF0C\u7528\u4E8E\u5728\u906E\u7F69\u5C42\u4E0A\u65B9\u5D4C\u5165\u5185\u5BB9 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-panel": "@vant/weapp/panel/index"
-}
-
\u9762\u677F\u53EA\u662F\u4E00\u4E2A\u5BB9\u5668\uFF0C\u91CC\u9762\u53EF\u4EE5\u653E\u5165\u81EA\u5B9A\u4E49\u7684\u5185\u5BB9\u3002
<van-panel title="\u6807\u9898" desc="\u63CF\u8FF0\u4FE1\u606F" status="\u72B6\u6001">
- <view>\u5185\u5BB9</view>
-</van-panel>
-
\u4F7F\u7528slot
\u81EA\u5B9A\u4E49\u5185\u5BB9\u3002
<van-panel title="\u6807\u9898" desc="\u63CF\u8FF0\u4FE1\u606F" status="\u72B6\u6001">
- <view>\u5185\u5BB9</view>
- <view slot="footer">
- <van-button size="small">\u6309\u94AE</van-button>
- <van-button size="small" type="danger">\u6309\u94AE</van-button>
- </view>
-</van-panel>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u6807\u9898 | string | - |
desc | \u63CF\u8FF0 | string | - |
status | \u72B6\u6001 | string | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u5185\u5BB9 |
header | \u81EA\u5B9A\u4E49 header\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86title \u3001desc \u3001status \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
footer | \u81EA\u5B9A\u4E49 footer |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
header-class | \u5934\u90E8\u6837\u5F0F\u7C7B |
footer-class | \u5E95\u90E8\u6837\u5F0F\u7C7B |
\u63D0\u4F9B\u591A\u4E2A\u9009\u9879\u96C6\u5408\u4F9B\u7528\u6237\u9009\u62E9\uFF0C\u652F\u6301\u5355\u5217\u9009\u62E9\u548C\u591A\u5217\u7EA7\u8054\uFF0C\u901A\u5E38\u4E0E \u5F39\u51FA\u5C42 \u7EC4\u4EF6\u914D\u5408\u4F7F\u7528\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-picker": "@vant/weapp/picker/index"
-}
-
<van-picker columns="{{ columns }}" bind:change="onChange" />
-
import Toast from '@vant/weapp/toast/toast';
-
-Page({
- data: {
- columns: ['\u676D\u5DDE', '\u5B81\u6CE2', '\u6E29\u5DDE', '\u5609\u5174', '\u6E56\u5DDE'],
- },
-
- onChange(event) {
- const { picker, value, index } = event.detail;
- Toast(\`\u5F53\u524D\u503C\uFF1A\${value}, \u5F53\u524D\u7D22\u5F15\uFF1A\${index}\`);
- },
-});
-
\u5355\u5217\u9009\u62E9\u5668\u53EF\u4EE5\u76F4\u63A5\u901A\u8FC7default-index
\u5C5E\u6027\u8BBE\u7F6E\u521D\u59CB\u9009\u4E2D\u9879\u7684\u7D22\u5F15\u503C\u3002
<van-picker
- columns="{{ columns }}"
- default-index="{{ 2 }}"
- bind:change="onChange"
-/>
-
<van-picker
- show-toolbar
- title="\u6807\u9898"
- columns="{{ columns }}"
- bind:cancel="onCancel"
- bind:confirm="onConfirm"
-/>
-
import Toast from '@vant/weapp/toast/toast';
-
-Page({
- data: {
- columns: ['\u676D\u5DDE', '\u5B81\u6CE2', '\u6E29\u5DDE', '\u5609\u5174', '\u6E56\u5DDE'],
- },
-
- onConfirm(event) {
- const { picker, value, index } = event.detail;
- Toast(\`\u5F53\u524D\u503C\uFF1A\${value}, \u5F53\u524D\u7D22\u5F15\uFF1A\${index}\`);
- },
-
- onCancel() {
- Toast('\u53D6\u6D88');
- },
-});
-
<van-picker columns="{{ columns }}" bind:change="onChange" />
-
const citys = {
- \u6D59\u6C5F: ['\u676D\u5DDE', '\u5B81\u6CE2', '\u6E29\u5DDE', '\u5609\u5174', '\u6E56\u5DDE'],
- \u798F\u5EFA: ['\u798F\u5DDE', '\u53A6\u95E8', '\u8386\u7530', '\u4E09\u660E', '\u6CC9\u5DDE'],
-};
-
-Page({
- data: {
- columns: [
- {
- values: Object.keys(citys),
- className: 'column1',
- },
- {
- values: citys['\u6D59\u6C5F'],
- className: 'column2',
- defaultIndex: 2,
- },
- ],
- },
-
- onChange(event) {
- const { picker, value, index } = event.detail;
- picker.setColumnValues(1, citys[value[0]]);
- },
-});
-
\u9009\u9879\u53EF\u4EE5\u4E3A\u5BF9\u8C61\u7ED3\u6784\uFF0C\u901A\u8FC7\u8BBE\u7F6E disabled \u6765\u7981\u7528\u8BE5\u9009\u9879\u3002
<van-picker columns="{{ columns }}" />
-
Page({
- data: {
- columns: [
- { text: '\u676D\u5DDE', disabled: true },
- { text: '\u5B81\u6CE2' },
- { text: '\u6E29\u5DDE' },
- ],
- },
-});
-
\u5F53 Picker \u6570\u636E\u662F\u901A\u8FC7\u5F02\u6B65\u83B7\u53D6\u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7 loading
\u5C5E\u6027\u663E\u793A\u52A0\u8F7D\u63D0\u793A\u3002
<van-picker columns="{{ columns }}" loading />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
columns | \u5BF9\u8C61\u6570\u7EC4\uFF0C\u914D\u7F6E\u6BCF\u4E00\u5217\u663E\u793A\u7684\u6570\u636E | Array | [] |
show-toolbar | \u662F\u5426\u663E\u793A\u9876\u90E8\u680F | boolean | false |
toolbar-position | \u9876\u90E8\u680F\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3Abottom | string | top |
title | \u9876\u90E8\u680F\u6807\u9898 | string | '' |
loading | \u662F\u5426\u663E\u793A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
value-key | \u9009\u9879\u5BF9\u8C61\u4E2D\uFF0C\u6587\u5B57\u5BF9\u5E94\u7684 key | string | text |
item-height | \u9009\u9879\u9AD8\u5EA6 | number | 44 |
confirm-button-text | \u786E\u8BA4\u6309\u94AE\u6587\u5B57 | string | \u786E\u8BA4 |
cancel-button-text | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | \u53D6\u6D88 |
visible-item-count | \u53EF\u89C1\u7684\u9009\u9879\u4E2A\u6570 | number | 6 |
default-index | \u5355\u5217\u9009\u62E9\u5668\u7684\u9ED8\u8BA4\u9009\u4E2D\u9879\u7D22\u5F15\uFF0C \u591A\u5217\u9009\u62E9\u5668\u8BF7\u53C2\u8003\u4E0B\u65B9\u7684 Columns \u914D\u7F6E | number | 0 |
Picker \u7EC4\u4EF6\u7684\u4E8B\u4EF6\u4F1A\u6839\u636E columns \u662F\u5355\u5217\u6216\u591A\u5217\u8FD4\u56DE\u4E0D\u540C\u7684\u53C2\u6570\u3002
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:confirm | \u70B9\u51FB\u5B8C\u6210\u6309\u94AE\u65F6\u89E6\u53D1 | \u5355\u5217\uFF1A\u9009\u4E2D\u503C\uFF0C\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 \u591A\u5217\uFF1A\u6240\u6709\u5217\u9009\u4E2D\u503C\uFF0C\u6240\u6709\u5217\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 |
bind:cancel | \u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1 | \u5355\u5217\uFF1A\u9009\u4E2D\u503C\uFF0C\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 \u591A\u5217\uFF1A\u6240\u6709\u5217\u9009\u4E2D\u503C\uFF0C\u6240\u6709\u5217\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 |
bind:change | \u9009\u9879\u6539\u53D8\u65F6\u89E6\u53D1 | \u5355\u5217\uFF1APicker \u5B9E\u4F8B\uFF0C\u9009\u4E2D\u503C\uFF0C\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 \u591A\u5217\uFF1APicker \u5B9E\u4F8B\uFF0C\u6240\u6709\u5217\u9009\u4E2D\u503C\uFF0C\u5F53\u524D\u5217\u5BF9\u5E94\u7684\u7D22\u5F15 |
\u5F53\u4F20\u5165\u591A\u5217\u6570\u636E\u65F6\uFF0Ccolumns
\u4E3A\u4E00\u4E2A\u5BF9\u8C61\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E00\u4E2A\u5BF9\u8C61\u914D\u7F6E\u6BCF\u4E00\u5217\uFF0C\u6BCF\u4E00\u5217\u6709\u4EE5\u4E0Bkey
\u3002
key | \u8BF4\u660E |
---|---|
values | \u5217\u4E2D\u5BF9\u5E94\u7684\u5907\u9009\u503C |
defaultIndex | \u521D\u59CB\u9009\u4E2D\u9879\u7684\u7D22\u5F15\uFF0C\u9ED8\u8BA4\u4E3A 0 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
active-class | \u9009\u4E2D\u9879\u6837\u5F0F\u7C7B |
toolbar-class | \u9876\u90E8\u680F\u6837\u5F0F\u7C7B |
column-class | \u5217\u6837\u5F0F\u7C7B |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 picker \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
getValues | - | values | \u83B7\u53D6\u6240\u6709\u5217\u9009\u4E2D\u7684\u503C |
setValues | values | - | \u8BBE\u7F6E\u6240\u6709\u5217\u9009\u4E2D\u7684\u503C |
getIndexes | - | indexes | \u83B7\u53D6\u6240\u6709\u5217\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 |
setIndexes | indexes | - | \u8BBE\u7F6E\u6240\u6709\u5217\u9009\u4E2D\u503C\u5BF9\u5E94\u7684\u7D22\u5F15 |
getColumnValue | columnIndex | value | \u83B7\u53D6\u5BF9\u5E94\u5217\u9009\u4E2D\u7684\u503C |
setColumnValue | columnIndex, value | - | \u8BBE\u7F6E\u5BF9\u5E94\u5217\u9009\u4E2D\u7684\u503C |
getColumnIndex | columnIndex | optionIndex | \u83B7\u53D6\u5BF9\u5E94\u5217\u9009\u4E2D\u9879\u7684\u7D22\u5F15 |
setColumnIndex | columnIndex, optionIndex | - | \u8BBE\u7F6E\u5BF9\u5E94\u5217\u9009\u4E2D\u9879\u7684\u7D22\u5F15 |
getColumnValues | columnIndex | values | \u83B7\u53D6\u5BF9\u5E94\u5217\u4E2D\u6240\u6709\u9009\u9879 |
setColumnValues | columnIndex, values | - | \u8BBE\u7F6E\u5BF9\u5E94\u5217\u4E2D\u6240\u6709\u9009\u9879 |
\u5F39\u51FA\u5C42\u5BB9\u5668\uFF0C\u7528\u4E8E\u5C55\u793A\u5F39\u7A97\u3001\u4FE1\u606F\u63D0\u793A\u7B49\u5185\u5BB9\uFF0C\u652F\u6301\u591A\u4E2A\u5F39\u51FA\u5C42\u53E0\u52A0\u5C55\u793A\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-popup": "@vant/weapp/popup/index"
-}
-
\u901A\u8FC7show
\u5C5E\u6027\u63A7\u5236\u5F39\u51FA\u5C42\u662F\u5426\u5C55\u793A\u3002
<van-cell title="\u5C55\u793A\u5F39\u51FA\u5C42" is-link bind:click="showPopup" />
-
-<van-popup show="{{ show }}" bind:close="onClose">\u5185\u5BB9</van-popup>
-
Page({
- data: {
- show: false,
- },
-
- showPopup() {
- this.setData({ show: true });
- },
-
- onClose() {
- this.setData({ show: false });
- },
-});
-
\u901A\u8FC7position
\u5C5E\u6027\u8BBE\u7F6E\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u9ED8\u8BA4\u5C45\u4E2D\u5F39\u51FA\uFF0C\u53EF\u4EE5\u8BBE\u7F6E\u4E3Atop
\u3001bottom
\u3001left
\u3001right
\u3002
<van-popup
- show="{{ show }}"
- position="top"
- custom-style="height: 20%;"
- bind:close="onClose"
-/>
-
\u8BBE\u7F6Ecloseable
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u5F39\u51FA\u5C42\u7684\u53F3\u4E0A\u89D2\u663E\u793A\u5173\u95ED\u56FE\u6807\uFF0C\u5E76\u4E14\u53EF\u4EE5\u901A\u8FC7close-icon
\u5C5E\u6027\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u4F7F\u7528close-icon-position
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\u4F4D\u7F6E\u3002
<van-popup
- show="{{ show }}"
- closeable
- position="bottom"
- custom-style="height: 20%"
- bind:close="onClose"
-/>
-
-<!-- \u81EA\u5B9A\u4E49\u56FE\u6807 -->
-<van-popup
- show="{{ show }}"
- closeable
- close-icon="close"
- position="bottom"
- custom-style="height: 20%"
- bind:close="onClose"
-/>
-
-<!-- \u56FE\u6807\u4F4D\u7F6E -->
-<van-popup
- show="{{ show }}"
- closeable
- close-icon-position="top-left"
- position="bottom"
- custom-style="height: 20%"
- bind:close="onClose"
-/>
-
\u8BBE\u7F6Eround
\u5C5E\u6027\u540E\uFF0C\u5F39\u7A97\u4F1A\u6839\u636E\u5F39\u51FA\u4F4D\u7F6E\u6DFB\u52A0\u4E0D\u540C\u7684\u5706\u89D2\u6837\u5F0F\u3002
<van-popup
- show="{{ show }}"
- round
- position="bottom"
- custom-style="height: 20%"
- bind:close="onClose"
-/>
-
\u4F7F\u7528\u7EC4\u4EF6\u65F6\uFF0C\u4F1A\u53D1\u73B0\u5185\u5BB9\u90E8\u5206\u6EDA\u52A8\u5230\u5E95\u65F6\uFF0C\u7EE7\u7EED\u5212\u52A8\u4F1A\u5BFC\u81F4\u5E95\u5C42\u9875\u9762\u7684\u6EDA\u52A8\uFF0C\u8FD9\u5C31\u662F\u6EDA\u52A8\u7A7F\u900F\u3002
\u76EE\u524D\uFF0C\u7EC4\u4EF6\u53EF\u4EE5\u901A\u8FC7 lock-scroll
\u5C5E\u6027\u5904\u7406\u90E8\u5206\u6EDA\u52A8\u7A7F\u900F\u95EE\u9898\u3002 \u4F46\u7531\u4E8E\u5C0F\u7A0B\u5E8F\u81EA\u8EAB\u539F\u56E0\uFF0C\u5F39\u7A97\u5185\u5BB9\u533A\u57DF\u4ECD\u4F1A\u51FA\u73B0\u6EDA\u52A8\u7A7F\u900F\u3002 \u4E0D\u8FC7\uFF0C\u6211\u4EEC\u4E3A\u5F00\u53D1\u8005\u63D0\u4F9B\u4E86\u4E00\u4E2A\u63A8\u8350\u65B9\u6848\u4EE5\u5B8C\u6574\u89E3\u51B3\u6EDA\u52A8\u7A7F\u900F\uFF1A
\u5F53\u5C0F\u7A0B\u5E8F\u57FA\u7840\u5E93\u6700\u4F4E\u7248\u672C\u5728 2.9.0 \u4EE5\u4E0A\u65F6\uFF0C\u5373\u53EF\u4F7F\u7528 page-meta \u7EC4\u4EF6\u52A8\u6001\u4FEE\u6539\u9875\u9762\u6837\u5F0F
<!-- page-meta \u53EA\u80FD\u662F\u9875\u9762\u5185\u7684\u7B2C\u4E00\u4E2A\u8282\u70B9 -->
-<page-meta page-style="{{ show ? 'overflow: hidden;' : '' }}" />
-
-<van-popup show="{{ show }}" catch:touchstart />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u663E\u793A\u5F39\u51FA\u5C42 | boolean | false |
z-index | z-index \u5C42\u7EA7 | number | 100 |
overlay | \u662F\u5426\u663E\u793A\u906E\u7F69\u5C42 | boolean | true |
position | \u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top bottom right left | string | center |
duration | \u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2 | number | object | 300 |
round | \u662F\u5426\u663E\u793A\u5706\u89D2 | boolean | false |
custom-style | \u81EA\u5B9A\u4E49\u5F39\u51FA\u5C42\u6837\u5F0F | string | '' |
overlay-style | \u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F | string | '' |
close-on-click-overlay | \u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED | boolean | true |
closeable | \u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807 | boolean | false |
close-icon | \u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5 | string | cross |
close-icon-position | \u5173\u95ED\u56FE\u6807\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top-left bottom-left bottom-right | string | top-right |
safe-area-inset-bottom | \u662F\u5426\u4E3A iPhoneX \u7559\u51FA\u5E95\u90E8\u5B89\u5168\u8DDD\u79BB | boolean | true |
safe-area-inset-top | \u662F\u5426\u7559\u51FA\u9876\u90E8\u5B89\u5168\u8DDD\u79BB\uFF08\u72B6\u6001\u680F\u9AD8\u5EA6\uFF09 | boolean | false |
safe-area-tab-bar | \u662F\u5426\u7559\u51FA\u5E95\u90E8 tabbar \u5B89\u5168\u8DDD\u79BB\uFF08\u5728\u4F7F\u7528 tabbar \u7EC4\u4EF6 & \u5C0F\u7A0B\u5E8F\u81EA\u5B9A\u4E49 tabbar \u65F6\uFF0Cpopup \u7EC4\u4EF6\u5C42\u7EA7\u65E0\u6CD5\u76D6\u4F4F tabbar\uFF09 | boolean | false |
lock-scroll v1.7.3 | \u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8 | boolean | true |
root-portal v1.10.14 | \u662F\u5426\u4ECE\u9875\u9762\u4E2D\u8131\u79BB\u51FA\u6765\uFF0C\u7528\u4E8E\u89E3\u51B3\u5404\u79CD fixed \u5931\u6548\u95EE\u9898\uFF0C\u5FAE\u4FE1\u57FA\u7840\u5E93 >= 2.25.2 | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:close | \u5173\u95ED\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1 | - |
bind:click-overlay | \u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u89E6\u53D1 | - |
bind:before-enter | \u8FDB\u5165\u524D\u89E6\u53D1 | - |
bind:enter | \u8FDB\u5165\u4E2D\u89E6\u53D1 | - |
bind:after-enter | \u8FDB\u5165\u540E\u89E6\u53D1 | - |
bind:before-leave | \u79BB\u5F00\u524D\u89E6\u53D1 | - |
bind:leave | \u79BB\u5F00\u4E2D\u89E6\u53D1 | - |
bind:after-leave | \u79BB\u5F00\u540E\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5C55\u793A\u64CD\u4F5C\u7684\u5F53\u524D\u8FDB\u5EA6\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-progress": "@vant/weapp/progress/index"
-}
-
\u8FDB\u5EA6\u6761\u9ED8\u8BA4\u4E3A\u84DD\u8272\uFF0C\u4F7F\u7528percentage
\u5C5E\u6027\u6765\u8BBE\u7F6E\u5F53\u524D\u8FDB\u5EA6\u3002
<van-progress percentage="50" />
-
\u901A\u8FC7stroke-width
\u53EF\u4EE5\u8BBE\u7F6E\u8FDB\u5EA6\u6761\u7684\u7C97\u7EC6\u3002
<van-progress :percentage="50" stroke-width="8" />
-
\u8BBE\u7F6Einactive
\u5C5E\u6027\u540E\u8FDB\u5EA6\u6761\u5C06\u7F6E\u7070\u3002
<van-progress inactive percentage="50" />
-
\u53EF\u4EE5\u4F7F\u7528pivot-text
\u5C5E\u6027\u81EA\u5B9A\u4E49\u6587\u5B57\uFF0Ccolor
\u5C5E\u6027\u81EA\u5B9A\u4E49\u8FDB\u5EA6\u6761\u989C\u8272\u3002
<van-progress pivot-text="\u6A59\u8272" color="#f2826a" percentage="25" />
-
-<van-progress pivot-text="\u7EA2\u8272" color="#ee0a24" percentage="50" />
-
-<van-progress
- percentage="75"
- pivot-text="\u7D2B\u8272"
- pivot-color="#7232dd"
- color="linear-gradient(to right, #be99ff, #7232dd)"
-/>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
inactive | \u662F\u5426\u7F6E\u7070 | boolean | false |
percentage | \u8FDB\u5EA6\u767E\u5206\u6BD4 | number | 0 |
stroke-width | \u8FDB\u5EA6\u6761\u7C97\u7EC6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 4px |
show-pivot | \u662F\u5426\u663E\u793A\u8FDB\u5EA6\u6587\u5B57 | boolean | true |
color | \u8FDB\u5EA6\u6761\u989C\u8272 | string | #1989fa |
text-color | \u8FDB\u5EA6\u6587\u5B57\u989C\u8272 | string | #fff |
track-color | \u8F68\u9053\u989C\u8272 | string | #e5e5e5 |
pivot-text | \u6587\u5B57\u663E\u793A | string | \u767E\u5206\u6BD4\u6587\u5B57 |
pivot-color | \u6587\u5B57\u80CC\u666F\u8272 | string | \u4E0E\u8FDB\u5EA6\u6761\u989C\u8272\u4E00\u81F4 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u5728\u4E00\u7EC4\u5907\u9009\u9879\u4E2D\u8FDB\u884C\u5355\u9009\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-radio": "@vant/weapp/radio/index",
- "van-radio-group": "@vant/weapp/radio-group/index"
-}
-
\u901A\u8FC7value
\u7ED1\u5B9A\u503C\u5F53\u524D\u9009\u4E2D\u9879\u7684 name \u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio name="1">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
Page({
- data: {
- radio: '1',
- },
-
- onChange(event) {
- this.setData({
- radio: event.detail,
- });
- },
-});
-
\u5C06direction
\u5C5E\u6027\u8BBE\u7F6E\u4E3Ahorizontal
\u540E\uFF0C\u5355\u9009\u6846\u7EC4\u4F1A\u53D8\u6210\u6C34\u5E73\u6392\u5217\u3002
<van-radio-group
- value="{{ radio }}"
- bind:change="onChange"
- direction="horizontal"
->
- <van-radio name="1">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u901A\u8FC7disabled
\u5C5E\u6027\u7981\u6B62\u9009\u9879\u5207\u6362\uFF0C\u5728Radio
\u4E0A\u8BBE\u7F6Ediabled
\u53EF\u4EE5\u7981\u7528\u5355\u4E2A\u9009\u9879\u3002
<van-radio-group value="{{ radio }}" disabled bind:change="onChange">
- <van-radio name="1">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u5C06shape
\u5C5E\u6027\u8BBE\u7F6E\u4E3Asquare
\uFF0C\u5355\u9009\u6846\u7684\u5F62\u72B6\u4F1A\u53D8\u6210\u65B9\u5F62\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio name="1" shape="square">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2" shape="square">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u901A\u8FC7checked-color
\u5C5E\u6027\u8BBE\u7F6E\u9009\u4E2D\u72B6\u6001\u7684\u56FE\u6807\u989C\u8272\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio name="1" checked-color="#07c160">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2" checked-color="#07c160">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u901A\u8FC7icon-size
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\u7684\u5927\u5C0F\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio name="1" icon-size="24px">\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2" icon-size="24px">\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u901A\u8FC7icon
\u63D2\u69FD\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u9700\u8981\u8BBE\u7F6Euse-icon-slot
\u5C5E\u6027\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio use-icon-slot value="{{ radio }}" name="1">
- \u81EA\u5B9A\u4E49\u56FE\u6807
- <image slot="icon" src="{{ radio === '1' ? icon.active : icon.normal }}" />
- </van-radio>
- <van-radio use-icon-slot value="{{ radio }}" name="2">
- \u81EA\u5B9A\u4E49\u56FE\u6807
- <image slot="icon" src="{{ radio === '2' ? icon.active : icon.normal }}" />
- </van-radio>
-</van-radio-group>
-
Page({
- data: {
- radio: true,
- icon: {
- normal: '//img.yzcdn.cn/icon-normal.png',
- active: '//img.yzcdn.cn/icon-active.png',
- },
- },
- onChange(event) {
- this.setData({
- radio: event.detail,
- });
- },
-});
-
\u901A\u8FC7\u8BBE\u7F6Elabel-disabled
\u5C5E\u6027\u53EF\u4EE5\u7981\u7528\u5355\u9009\u6846\u6587\u672C\u70B9\u51FB\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-radio name="1" label-disabled>\u5355\u9009\u6846 1</van-radio>
- <van-radio name="2" label-disabled>\u5355\u9009\u6846 2</van-radio>
-</van-radio-group>
-
\u6B64\u65F6\u4F60\u9700\u8981\u518D\u5F15\u5165Cell
\u548CCellGroup
\u7EC4\u4EF6\u3002
<van-radio-group value="{{ radio }}" bind:change="onChange">
- <van-cell-group>
- <van-cell title="\u5355\u9009\u6846 1" clickable data-name="1" bind:click="onClick">
- <van-radio slot="right-icon" name="1" />
- </van-cell>
- <van-cell title="\u5355\u9009\u6846 2" clickable data-name="2" bind:click="onClick">
- <van-radio slot="right-icon" name="2" />
- </van-cell>
- </van-cell-group>
-</van-radio-group>
-
Page({
- data: {
- radio: '1',
- },
-
- onChange(event) {
- this.setData({
- radio: event.detail,
- });
- },
-
- onClick(event) {
- const { name } = event.currentTarget.dataset;
- this.setData({
- radio: name,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
value | \u5F53\u524D\u9009\u4E2D\u9879\u7684\u6807\u8BC6\u7B26 | any | - |
disabled | \u662F\u5426\u7981\u7528\u6240\u6709\u5355\u9009\u6846 | boolean | false |
direction v1.6.7 | \u6392\u5217\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A horizontal | string | vertical |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u8BC6\u7B26 | string | - |
shape | \u5F62\u72B6\uFF0C\u53EF\u9009\u503C\u4E3A square | string | round |
disabled | \u662F\u5426\u4E3A\u7981\u7528\u72B6\u6001 | boolean | false |
label-disabled | \u662F\u5426\u7981\u7528\u6587\u672C\u5185\u5BB9\u70B9\u51FB | boolean | false |
label-position | \u6587\u672C\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A left | string | right |
icon-size | \u56FE\u6807\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 20px |
checked-color | \u9009\u4E2D\u72B6\u6001\u989C\u8272 | string | #1989fa |
use-icon-slot | \u662F\u5426\u4F7F\u7528 icon \u63D2\u69FD | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u7ED1\u5B9A\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D\u9009\u4E2D\u9879\u7684 name |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
icon-class | \u56FE\u6807\u6837\u5F0F\u7C7B |
label-class | \u63CF\u8FF0\u4FE1\u606F\u6837\u5F0F\u7C7B |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u7ED1\u5B9A\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | \u5F53\u524D\u9009\u4E2D\u9879\u7684 name |
\u7528\u4E8E\u5BF9\u4E8B\u7269\u8FDB\u884C\u8BC4\u7EA7\u64CD\u4F5C\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-rate": "@vant/weapp/rate/index"
-}
-
<van-rate value="{{ value }}" bind:change="onChange" />
-
Page({
- data: {
- value: 3,
- },
-
- onChange(event) {
- this.setData({
- value: event.detail,
- });
- },
-});
-
<van-rate
- value="{{ value }}"
- icon="like"
- void-icon="like-o"
- bind:change="onChange"
-/>
-
<van-rate
- value="{{ value }}"
- size="{{ 25 }}"
- color="#ffd21e"
- void-icon="star"
- void-color="#eee"
- bind:change="onChange"
-/>
-
<van-rate
- value="{{ value }}"
- allow-half
- void-icon="star"
- void-color="#eee"
- bind:change="onChange"
-/>
-
Page({
- data: {
- value: 2.5,
- },
-
- onChange(event) {
- this.setData({
- value: event.detail,
- });
- },
-});
-
<van-rate value="{{ value }}" count="{{ 6 }}" bind:change="onChange" />
-
<van-rate disabled value="{{ value }}" bind:change="onChange" />
-
<van-rate readonly value="{{ value }}" bind:change="onChange" />
-
\u8BC4\u5206\u53D8\u5316\u65F6\uFF0C\u4F1A\u89E6\u53D1 change
\u4E8B\u4EF6\u3002
<van-rate value="{{ value }}" bind:change="onChange" />
-
Page({
- data: {
- value: 2,
- },
-
- onChange(event) {
- Toast('\u5F53\u524D\u503C\uFF1A' + event.detail);
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
value | \u5F53\u524D\u5206\u503C | number | - |
count | \u56FE\u6807\u603B\u6570 | number | 5 |
size | \u56FE\u6807\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | string | number | 20px |
gutter | \u56FE\u6807\u95F4\u8DDD\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | string | number | 4px |
color | \u9009\u4E2D\u65F6\u7684\u989C\u8272 | string | #ffd21e |
void-color | \u672A\u9009\u4E2D\u65F6\u7684\u989C\u8272 | string | #c7c7c7 |
icon | \u9009\u4E2D\u65F6\u7684\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | star |
void-icon | \u672A\u9009\u4E2D\u65F6\u7684\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | star-o |
allow-half | \u662F\u5426\u5141\u8BB8\u534A\u9009 | boolean | false |
readonly | \u662F\u5426\u4E3A\u53EA\u8BFB\u72B6\u6001 | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u8BC4\u5206 | boolean | false |
disabled-color | \u7981\u7528\u65F6\u7684\u989C\u8272 | string | #bdbdbd |
touchable | \u662F\u5426\u53EF\u4EE5\u901A\u8FC7\u6ED1\u52A8\u624B\u52BF\u9009\u62E9\u8BC4\u5206 | boolean | true |
\u4E8B\u4EF6\u540D\u79F0 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u524D\u5206\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | event.detail:\u5F53\u524D\u5206\u503C |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
icon-class | \u56FE\u6807\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u641C\u7D22\u573A\u666F\u7684\u8F93\u5165\u6846\u7EC4\u4EF6\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-search": "@vant/weapp/search/index"
-}
-
van-search
\u4E2D\uFF0Cvalue \u7528\u4E8E\u63A7\u5236\u641C\u7D22\u6846\u4E2D\u7684\u6587\u5B57\u3002background \u53EF\u4EE5\u81EA\u5B9A\u4E49\u641C\u7D22\u6846\u5916\u90E8\u80CC\u666F\u8272\u3002
<van-search value="{{ value }}" placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD" />
-
van-search
\u63D0\u4F9B\u4E86 search \u548C cancel \u4E8B\u4EF6\u3002search \u4E8B\u4EF6\u5728\u7528\u6237\u70B9\u51FB\u952E\u76D8\u4E0A\u7684\u641C\u7D22\u6309\u94AE\u89E6\u53D1\u3002cancel \u4E8B\u4EF6\u5728\u7528\u6237\u70B9\u51FB\u641C\u7D22\u6846\u53F3\u4FA7\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1\u3002
<van-search
- value="{{ value }}"
- placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD"
- show-action
- bind:search="onSearch"
- bind:cancel="onCancel"
-/>
-
\u901A\u8FC7 input-align
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u641C\u7D22\u6846\u5185\u5BB9\u7684\u5BF9\u9F50\u65B9\u5F0F\u3002
<van-search
- value="{{ value }}"
- input-align="center"
- placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD"
-/>
-
\u901A\u8FC7 disabled
\u5C5E\u6027\u53EF\u4EE5\u5C06\u7EC4\u4EF6\u8BBE\u7F6E\u4E3A\u7981\u7528\u72B6\u6001\u3002
<van-search disabled value="{{ value }}" placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD" />
-
\u901A\u8FC7background
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u641C\u7D22\u6846\u5916\u90E8\u7684\u80CC\u666F\u8272\uFF0C\u901A\u8FC7shape
\u5C5E\u6027\u8BBE\u7F6E\u641C\u7D22\u6846\u7684\u5F62\u72B6\uFF0C\u53EF\u9009\u503C\u4E3Around
\u3002
<van-search
- value="{{ value }}"
- shape="round"
- background="#4fc08d"
- placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD"
-/>
-
van-search
\u652F\u6301\u81EA\u5B9A\u4E49\u53F3\u4FA7\u53D6\u6D88\u6309\u94AE\uFF0C\u4F7F\u7528\u540D\u5B57\u4E3A action \u7684 slot\uFF0C\u5E76\u8BBE\u7F6E use-action-slot \u4E3A true \u5373\u53EF\u3002
<van-search
- value="{{ value }}"
- label="\u5730\u5740"
- placeholder="\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD"
- use-action-slot
- bind:change="onChange"
- bind:search="onSearch"
->
- <view slot="action" bind:tap="onClick">\u641C\u7D22</view>
-</van-search>
-
Page({
- data: {
- value: '',
- },
- onChange(e) {
- this.setData({
- value: e.detail,
- });
- },
- onSearch() {
- Toast('\u641C\u7D22' + this.data.value);
- },
- onClick() {
- Toast('\u641C\u7D22' + this.data.value);
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
label | \u641C\u7D22\u6846\u5DE6\u4FA7\u6587\u672C | string | - |
shape | \u5F62\u72B6\uFF0C\u53EF\u9009\u503C\u4E3A round | string | square |
value | \u5F53\u524D\u8F93\u5165\u7684\u503C | string | number | - |
background | \u641C\u7D22\u6846\u80CC\u666F\u8272 | string | #f2f2f2 |
show-action | \u662F\u5426\u5728\u641C\u7D22\u6846\u53F3\u4FA7\u663E\u793A\u53D6\u6D88\u6309\u94AE | boolean | false |
action-text v1.0.0 | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | \u53D6\u6D88 |
focus | \u83B7\u53D6\u7126\u70B9 | boolean | false |
error | \u662F\u5426\u5C06\u8F93\u5165\u5185\u5BB9\u6807\u7EA2 | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u8F93\u5165\u6846 | boolean | false |
readonly | \u662F\u5426\u53EA\u8BFB | boolean | false |
clearable | \u662F\u5426\u542F\u7528\u6E05\u9664\u63A7\u4EF6 | boolean | true |
clear-trigger v1.8.4 | \u663E\u793A\u6E05\u9664\u56FE\u6807\u7684\u65F6\u673A\uFF0Calways \u8868\u793A\u8F93\u5165\u6846\u4E0D\u4E3A\u7A7A\u65F6\u5C55\u793A\uFF0Cfocus \u8868\u793A\u8F93\u5165\u6846\u805A\u7126\u4E14\u4E0D\u4E3A\u7A7A\u65F6\u5C55\u793A | string | focus |
clear-icon v1.8.4 | \u6E05\u9664\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5 | string | clear |
maxlength | \u6700\u5927\u8F93\u5165\u957F\u5EA6\uFF0C\u8BBE\u7F6E\u4E3A -1 \u7684\u65F6\u5019\u4E0D\u9650\u5236\u6700\u5927\u957F\u5EA6 | number | -1 |
use-action-slot | \u662F\u5426\u4F7F\u7528 action slot | boolean | false |
placeholder | \u8F93\u5165\u6846\u4E3A\u7A7A\u65F6\u5360\u4F4D\u7B26 | string | - |
placeholder-style | \u6307\u5B9A\u5360\u4F4D\u7B26\u7684\u6837\u5F0F | string | - |
input-align | \u8F93\u5165\u6846\u5185\u5BB9\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A center right | string | left |
use-left-icon-slot | \u662F\u5426\u4F7F\u7528\u8F93\u5165\u6846\u5DE6\u4FA7\u56FE\u6807 slot | boolean | false |
use-right-icon-slot | \u662F\u5426\u4F7F\u7528\u8F93\u5165\u6846\u53F3\u4FA7\u56FE\u6807 slot | boolean | false |
left-icon | \u8F93\u5165\u6846\u5DE6\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6\uFF08\u5982\u679C\u8BBE\u7F6E\u4E86 use-left-icon-slot\uFF0C\u5219\u8BE5\u5C5E\u6027\u65E0\u6548\uFF09 | string | search |
right-icon | \u8F93\u5165\u6846\u53F3\u4FA7\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6\uFF08\u5982\u679C\u8BBE\u7F6E\u4E86 use-right-icon-slot\uFF0C\u5219\u8BE5\u5C5E\u6027\u65E0\u6548\uFF09 | string | - |
cursor-spacing | \u8F93\u5165\u6846\u805A\u7126\u65F6\u5E95\u90E8\u4E0E\u952E\u76D8\u7684\u8DDD\u79BB | number | 0 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:search | \u786E\u5B9A\u641C\u7D22\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u8F93\u5165\u503C |
bind:change | \u8F93\u5165\u5185\u5BB9\u53D8\u5316\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u8F93\u5165\u503C |
bind:cancel | \u53D6\u6D88\u641C\u7D22\u641C\u7D22\u65F6\u89E6\u53D1 | - |
bind:focus | \u8F93\u5165\u6846\u805A\u7126\u65F6\u89E6\u53D1 | - |
bind:blur | \u8F93\u5165\u6846\u5931\u7126\u65F6\u89E6\u53D1 | - |
bind:clear | \u70B9\u51FB\u6E05\u7A7A\u63A7\u4EF6\u65F6\u89E6\u53D1 | - |
bind:click-input | \u70B9\u51FB\u641C\u7D22\u533A\u57DF\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
action | \u81EA\u5B9A\u4E49\u641C\u7D22\u6846\u53F3\u4FA7\u6309\u94AE\uFF0C\u9700\u8981\u5728use-action-slot \u4E3A true \u65F6\u624D\u4F1A\u663E\u793A |
label | \u81EA\u5B9A\u4E49\u641C\u7D22\u6846\u5DE6\u4FA7\u6587\u672C |
left-icon | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u5DE6\u4FA7\u56FE\u6807\uFF0C\u9700\u8981\u5728use-left-icon-slot \u4E3A true \u65F6\u624D\u4F1A\u663E\u793A |
right-icon | \u81EA\u5B9A\u4E49\u8F93\u5165\u6846\u53F3\u4FA7\u56FE\u6807\uFF0C\u9700\u8981\u5728use-right-icon-slot \u4E3A true \u65F6\u624D\u4F1A\u663E\u793A |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
field-class | \u641C\u7D22\u6846\u6837\u5F0F\u7C7B |
input-class | \u8F93\u5165\u6846\u6837\u5F0F\u7C7B |
cancel-class | \u53D6\u6D88\u6309\u94AE\u6837\u5F0F\u7C7B |
\u5E95\u90E8\u5F39\u8D77\u7684\u5206\u4EAB\u9762\u677F\uFF0C\u7528\u4E8E\u5C55\u793A\u5404\u5206\u4EAB\u6E20\u9053\u5BF9\u5E94\u7684\u64CD\u4F5C\u6309\u94AE\uFF0C\u4E0D\u542B\u5177\u4F53\u7684\u5206\u4EAB\u903B\u8F91\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-share-sheet": "@vant/weapp/share-sheet/index"
-}
-
\u5206\u4EAB\u9762\u677F\u901A\u8FC7 options
\u5C5E\u6027\u6765\u5B9A\u4E49\u5206\u4EAB\u9009\u9879\uFF0C\u6570\u7EC4\u7684\u6BCF\u4E00\u9879\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF0C\u5BF9\u8C61\u683C\u5F0F\u89C1\u6587\u6863\u4E0B\u65B9\u8868\u683C\u3002
<van-cell title="\u663E\u793A\u5206\u4EAB\u9762\u677F" bind:click="onClick" />
-<van-share-sheet
- show="{{ showShare }}"
- title="\u7ACB\u5373\u5206\u4EAB\u7ED9\u597D\u53CB"
- options="{{ options }}"
- bind:select="onSelect"
- bind:close="onClose"
-/>
-
Page({
- data: {
- showShare: false,
- options: [
- { name: '\u5FAE\u4FE1', icon: 'wechat', openType: 'share' },
- { name: '\u5FAE\u535A', icon: 'weibo' },
- { name: '\u590D\u5236\u94FE\u63A5', icon: 'link' },
- { name: '\u5206\u4EAB\u6D77\u62A5', icon: 'poster' },
- { name: '\u4E8C\u7EF4\u7801', icon: 'qrcode' },
- ],
- },
-
- onClick(event) {
- this.setData({ showShare: true });
- },
-
- onClose() {
- this.setData({ showShare: false });
- },
-
- onSelect(event) {
- Toast(event.detail.name);
- this.onClose();
- },
-});
-
\u5F53\u5206\u4EAB\u9009\u9879\u7684\u6570\u91CF\u8F83\u591A\u65F6\uFF0C\u53EF\u4EE5\u5C06 options
\u5B9A\u4E49\u4E3A\u6570\u7EC4\u5D4C\u5957\u7684\u683C\u5F0F\uFF0C\u6BCF\u4E2A\u5B50\u6570\u7EC4\u4F1A\u4F5C\u4E3A\u4E00\u884C\u9009\u9879\u5C55\u793A\u3002
<van-share-sheet
- show="{{ showShare }}"
- title="\u7ACB\u5373\u5206\u4EAB\u7ED9\u597D\u53CB"
- options="{{ options }}"
-/>
-
Page({
- data: {
- showShare: false,
- options: [
- [
- { name: '\u5FAE\u4FE1', icon: 'wechat' },
- { name: '\u5FAE\u535A', icon: 'weibo' },
- { name: 'QQ', icon: 'qq' },
- ],
- [
- { name: '\u590D\u5236\u94FE\u63A5', icon: 'link' },
- { name: '\u5206\u4EAB\u6D77\u62A5', icon: 'poster' },
- { name: '\u4E8C\u7EF4\u7801', icon: 'qrcode' },
- ],
- ],
- },
-});
-
\u9664\u4E86\u4F7F\u7528\u5185\u7F6E\u7684\u51E0\u79CD\u56FE\u6807\u5916\uFF0C\u53EF\u4EE5\u76F4\u63A5\u5728 icon
\u4E2D\u4F20\u5165\u56FE\u7247 URL \u6765\u4F7F\u7528\u81EA\u5B9A\u4E49\u7684\u56FE\u6807\u3002
<van-share-sheet show="{{ showShare }}" options="{{ options }}" />
-
Page({
- data: {
- showShare: false,
- options: [
- {
- name: '\u540D\u79F0',
- icon: 'https://img.yzcdn.cn/vant/custom-icon-fire.png',
- },
- {
- name: '\u540D\u79F0',
- icon: 'https://img.yzcdn.cn/vant/custom-icon-light.png',
- },
- {
- name: '\u540D\u79F0',
- icon: 'https://img.yzcdn.cn/vant/custom-icon-water.png',
- },
- ],
- },
-});
-
\u901A\u8FC7 description
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u6807\u9898\u4E0B\u65B9\u7684\u63CF\u8FF0\u6587\u5B57, \u5728 options
\u5185\u8BBE\u7F6E description
\u5C5E\u6027\u53EF\u4EE5\u6DFB\u52A0\u5206\u4EAB\u9009\u9879\u63CF\u8FF0\u3002
<van-share-sheet
- show="{{ showShare }}"
- options="{{ options }}"
- title="\u7ACB\u5373\u5206\u4EAB\u7ED9\u597D\u53CB"
- description="\u63CF\u8FF0\u4FE1\u606F"
-/>
-
Page({
- data: {
- showShare: false,
- options: [
- { name: '\u5FAE\u4FE1', icon: 'wechat' },
- { name: '\u5FAE\u535A', icon: 'weibo' },
- {
- name: '\u590D\u5236\u94FE\u63A5',
- icon: 'link',
- description: '\u63CF\u8FF0\u4FE1\u606F',
- },
- { name: '\u5206\u4EAB\u6D77\u62A5', icon: 'poster' },
- { name: '\u4E8C\u7EF4\u7801', icon: 'qrcode' },
- ],
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
show | \u662F\u5426\u663E\u793A\u5206\u4EAB\u9762\u677F | boolean | false |
options | \u5206\u4EAB\u9009\u9879 | Option[] | [] |
title | \u9876\u90E8\u6807\u9898 | string | - |
cancel-text | \u53D6\u6D88\u6309\u94AE\u6587\u5B57 | string | '\u53D6\u6D88' |
description | \u6807\u9898\u4E0B\u65B9\u7684\u8F85\u52A9\u63CF\u8FF0\u6587\u5B57 | string | - |
duration | \u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u6BEB\u79D2 | number | string | 300 |
overlay | \u662F\u5426\u663E\u793A\u906E\u7F69\u5C42 | boolean | true |
close-on-click-overlay | \u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED | boolean | true |
safe-area-inset-bottom | \u662F\u5426\u5F00\u542F\u5E95\u90E8\u5B89\u5168\u533A\u9002\u914D | boolean | true |
options
\u5C5E\u6027\u4E3A\u4E00\u4E2A\u5BF9\u8C61\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E2A\u5BF9\u8C61\u914D\u7F6E\u4E00\u5217\uFF0C\u5BF9\u8C61\u53EF\u4EE5\u5305\u542B\u4EE5\u4E0B\u503C\uFF1A
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
name | \u5206\u4EAB\u6E20\u9053\u540D\u79F0 | string |
description | \u5206\u4EAB\u9009\u9879\u63CF\u8FF0 | string |
icon | \u56FE\u6807\uFF0C\u53EF\u9009\u503C\u4E3A qq link weibo wechat poster qrcode weapp-qrcode wechat-moments \uFF0C\u652F\u6301\u4F20\u5165\u56FE\u7247 URL | string |
openType | \u6309\u94AE open-type \uFF0C\u53EF\u7528\u4E8E\u5B9E\u73B0\u5206\u4EAB\u529F\u80FD\uFF0C\u53EF\u9009\u503C\u4E3A share | string |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:select | \u70B9\u51FB\u5206\u4EAB\u9009\u9879\u65F6\u89E6\u53D1 | option: Option, index: number |
bind:close | \u5173\u95ED\u65F6\u89E6\u53D1 | - |
bind:cancel | \u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:click-overlay | \u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49\u9876\u90E8\u6807\u9898 |
description | \u81EA\u5B9A\u4E49\u63CF\u8FF0\u6587\u5B57 |
\u5782\u76F4\u5C55\u793A\u7684\u5BFC\u822A\u680F\uFF0C\u7528\u4E8E\u5728\u4E0D\u540C\u7684\u5185\u5BB9\u533A\u57DF\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-sidebar": "@vant/weapp/sidebar/index",
- "van-sidebar-item": "@vant/weapp/sidebar-item/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u901A\u8FC7\u5728van-sidebar
\u4E0A\u8BBE\u7F6EactiveKey
\u5C5E\u6027\u6765\u63A7\u5236\u9009\u4E2D\u9879\u3002
<van-sidebar active-key="{{ activeKey }}">
- <van-sidebar-item title="\u6807\u7B7E\u540D" />
- <van-sidebar-item title="\u6807\u7B7E\u540D" />
- <van-sidebar-item title="\u6807\u7B7E\u540D" />
-</van-sidebar>
-
Page({
- data: {
- activeKey: 0,
- },
-});
-
\u8BBE\u7F6Edot
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\u3002\u8BBE\u7F6Ebadge
\u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002
<van-sidebar active-key="{{ activeKey }}">
- <van-sidebar-item title="\u6807\u7B7E\u540D" dot />
- <van-sidebar-item title="\u6807\u7B7E\u540D" badge="5" />
- <van-sidebar-item title="\u6807\u7B7E\u540D" badge="99+" />
-</van-sidebar>
-
\u901A\u8FC7disabled
\u5C5E\u6027\u7981\u7528\u9009\u9879\u3002
<van-sidebar active-key="{{ activeKey }}">
- <van-sidebar-item title="\u6807\u7B7E\u540D" />
- <van-sidebar-item title="\u6807\u7B7E\u540D" disabled />
- <van-sidebar-item title="\u6807\u7B7E\u540D" />
-</van-sidebar>
-
\u8BBE\u7F6Echange
\u65B9\u6CD5\u6765\u76D1\u542C\u5207\u6362\u5BFC\u822A\u9879\u65F6\u7684\u4E8B\u4EF6\u3002
<van-sidebar active-key="{{ activeKey }}" bind:change="onChange">
- <van-sidebar-item title="\u6807\u7B7E\u540D 1" />
- <van-sidebar-item title="\u6807\u7B7E\u540D 2" />
- <van-sidebar-item title="\u6807\u7B7E\u540D 3" />
-</van-sidebar>
-
-<van-notify id="van-notify" />
-
import Notify from '@vant/weapp/notify/notify';
-
-Page({
- data: {
- activeKey: 0,
- },
-
- onChange(event) {
- Notify({ type: 'primary', message: event.detail });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
activeKey | \u9009\u4E2D\u9879\u7684\u7D22\u5F15 | string | number | 0 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
change | \u5207\u6362\u5FBD\u7AE0\u65F6\u89E6\u53D1 | \u5F53\u524D\u9009\u4E2D\u5FBD\u7AE0\u7684\u7D22\u5F15 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
title | \u5185\u5BB9 | string | '' |
dot | \u662F\u5426\u663E\u793A\u53F3\u4E0A\u89D2\u5C0F\u7EA2\u70B9 | boolean | false |
info | \u56FE\u6807\u53F3\u4E0A\u89D2\u5FBD\u6807\u7684\u5185\u5BB9\uFF08\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 badge \u5C5E\u6027\uFF09 | string | number | '' |
badge v1.5.0 | \u56FE\u6807\u53F3\u4E0A\u89D2\u5FBD\u6807\u7684\u5185\u5BB9 | string | number | '' |
disabled | \u662F\u5426\u7981\u7528\u8BE5\u9879 | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
title | \u81EA\u5B9A\u4E49\u6807\u9898\u680F\uFF0C\u5982\u679C\u8BBE\u7F6E\u4E86title \u5C5E\u6027\u5219\u4E0D\u751F\u6548 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
click | \u70B9\u51FB\u5FBD\u7AE0\u65F6\u89E6\u53D1 | event.detail \u4E3A\u5F53\u524D\u5FBD\u7AE0\u7684\u7D22\u5F15 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5728\u5185\u5BB9\u52A0\u8F7D\u8FC7\u7A0B\u4E2D\u5C55\u793A\u4E00\u7EC4\u5360\u4F4D\u56FE\u5F62\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-skeleton": "@vant/weapp/skeleton/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u901A\u8FC7title
\u5C5E\u6027\u663E\u793A\u6807\u9898\u5360\u4F4D\u56FE\uFF0C\u901A\u8FC7row
\u5C5E\u6027\u914D\u7F6E\u5360\u4F4D\u6BB5\u843D\u884C\u6570\u3002
<van-skeleton title row="3" />
-
\u901A\u8FC7avatar
\u5C5E\u6027\u663E\u793A\u5934\u50CF\u5360\u4F4D\u56FE\u3002
<van-skeleton title avatar row="3" />
-
\u5C06loading
\u5C5E\u6027\u8BBE\u7F6E\u6210false
\u8868\u793A\u5185\u5BB9\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6B64\u65F6\u4F1A\u9690\u85CF\u5360\u4F4D\u56FE\uFF0C\u5E76\u663E\u793ASkeleton
\u7684\u5B50\u7EC4\u4EF6\u3002
<van-skeleton title avatar row="3" loading="{{ loading }}">
- <view>\u5B9E\u9645\u5185\u5BB9</view>
-</van-skeleton>
-
Page({
- data: {
- loading: true,
- },
- onReady() {
- this.setData({
- loading: false,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
row | \u6BB5\u843D\u5360\u4F4D\u56FE\u884C\u6570 | number | 0 |
row-width | \u6BB5\u843D\u5360\u4F4D\u56FE\u5BBD\u5EA6\uFF0C\u53EF\u4F20\u6570\u7EC4\u6765\u8BBE\u7F6E\u6BCF\u4E00\u884C\u7684\u5BBD\u5EA6 | string | string[] | 100% |
title | \u662F\u5426\u663E\u793A\u6807\u9898\u5360\u4F4D\u56FE | boolean | false |
title-width | \u6807\u9898\u5360\u4F4D\u56FE\u5BBD\u5EA6 | string | number | 40% |
avatar | \u662F\u5426\u663E\u793A\u5934\u50CF\u5360\u4F4D\u56FE | boolean | false |
avatar-size | \u5934\u50CF\u5360\u4F4D\u56FE\u5927\u5C0F | string | number | 32px |
avatar-shape | \u5934\u50CF\u5360\u4F4D\u56FE\u5F62\u72B6\uFF0C\u53EF\u9009\u503C\u4E3Asquare | string | round |
loading | \u662F\u5426\u663E\u793A\u5360\u4F4D\u56FE\uFF0C\u4F20false \u65F6\u4F1A\u5C55\u793A\u5B50\u7EC4\u4EF6\u5185\u5BB9 | boolean | true |
animate | \u662F\u5426\u5F00\u542F\u52A8\u753B | boolean | true |
\u6ED1\u52A8\u8F93\u5165\u6761\uFF0C\u7528\u4E8E\u5728\u7ED9\u5B9A\u7684\u8303\u56F4\u5185\u9009\u62E9\u4E00\u4E2A\u503C\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-slider": "@vant/weapp/slider/index"
-}
-
<van-slider value="50" bind:change="onChange" />
-
Page({
- onChange(event) {
- wx.showToast({
- icon: 'none',
- title: \`\u5F53\u524D\u503C\uFF1A\${event.detail}\`,
- });
- },
-});
-
\u6DFB\u52A0 range
\u5C5E\u6027\u5C31\u53EF\u4EE5\u5F00\u542F\u53CC\u6ED1\u5757\u6A21\u5F0F\uFF0C\u786E\u4FDD value
\u7684\u503C\u662F\u4E00\u4E2A\u6570\u7EC4\u3002
<van-slider value="{{ [10, 50] }}" range @change="onChange" />
-
Page({
- onChange(event) {
- wx.showToast({
- icon: 'none',
- title: \`\u5F53\u524D\u503C\uFF1A\${event.detail}\`,
- });
- },
-});
-
<van-slider min="-50" max="50" />
-
<van-slider value="50" disabled />
-
<van-slider value="50" step="10" />
-
<van-slider value="50" bar-height="4px" active-color="#ee0a24" />
-
<van-slider value="{{ currentValue }}" use-button-slot bind:drag="onDrag">
- <view class="custom-button" slot="button">{{ currentValue }}/100</view>
-</van-slider>
-
Page({
- data: {
- currentValue: 50,
- },
-
- onDrag(event) {
- this.setData({
- currentValue: event.detail.value,
- });
- },
-});
-
\u8BBE\u7F6E vertical
\u5C5E\u6027\u540E\uFF0C\u6ED1\u5757\u4F1A\u5782\u76F4\u5C55\u793A\uFF0C\u4E14\u9AD8\u5EA6\u4E3A 100% \u7236\u5143\u7D20\u9AD8\u5EA6\u3002
<view style="height: 150px;">
- <van-slider value="50" vertical bind:change="onChange" />
- <van-slider
- value="{{ [10, 50] }}"
- range
- vertical
- style="margin-left: 100px;"
- bind:change="onChange"
- />
-</view>
-
Page({
- onChange(event) {
- wx.showToast({
- icon: 'none',
- title: \`\u5F53\u524D\u503C\uFF1A\${event.detail}\`,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
value | \u5F53\u524D\u8FDB\u5EA6\u767E\u5206\u6BD4\uFF0C\u5728\u53CC\u6ED1\u5757\u6A21\u5F0F\u4E0B\u4E3A\u6570\u7EC4\u683C\u5F0F | number | number[] | 0 |
disabled | \u662F\u5426\u7981\u7528\u6ED1\u5757 | boolean | false |
max | \u6700\u5927\u503C | number | 100 |
min | \u6700\u5C0F\u503C | number | 0 |
step | \u6B65\u957F | number | 1 |
bar-height | \u8FDB\u5EA6\u6761\u9AD8\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | string | number | 2px |
active-color | \u8FDB\u5EA6\u6761\u6FC0\u6D3B\u6001\u989C\u8272 | string | #1989fa |
inactive-color | \u8FDB\u5EA6\u6761\u9ED8\u8BA4\u989C\u8272 | string | #e5e5e5 |
use-slot-button | \u662F\u5426\u4F7F\u7528\u6309\u94AE\u63D2\u69FD | boolean | false |
range v1.8.4 | \u662F\u5426\u5F00\u542F\u53CC\u6ED1\u5757\u6A21\u5F0F | boolean | false |
vertical v1.8.5 | \u662F\u5426\u5782\u76F4\u5C55\u793A | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:drag | \u62D6\u52A8\u8FDB\u5EA6\u6761\u65F6\u89E6\u53D1 | event.detail.value: \u5F53\u524D\u8FDB\u5EA6 |
bind:change | \u8FDB\u5EA6\u503C\u6539\u53D8\u540E\u89E6\u53D1 | event.detail: \u5F53\u524D\u8FDB\u5EA6 |
bind:drag-start | \u5F00\u59CB\u62D6\u52A8\u65F6\u89E6\u53D1 | - |
bind:drag-end | \u7ED3\u675F\u62D6\u52A8\u65F6\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u540D\u79F0 | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
button | \u81EA\u5B9A\u4E49\u6ED1\u5757\u6309\u94AE | { value: number } |
left-button v1.8.4 | \u81EA\u5B9A\u4E49\u5DE6\u4FA7\u6ED1\u5757\u6309\u94AE\uFF08\u53CC\u6ED1\u5757\u6A21\u5F0F\u4E0B\uFF09 | { value: number } |
right-button v1.8.4 | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u6ED1\u5757\u6309\u94AE \uFF08\u53CC\u6ED1\u5757\u6A21\u5F0F\u4E0B\uFF09 | { value: number } |
\u6B65\u8FDB\u5668\u7531\u589E\u52A0\u6309\u94AE\u3001\u51CF\u5C11\u6309\u94AE\u548C\u8F93\u5165\u6846\u7EC4\u6210\uFF0C\u7528\u4E8E\u5728\u4E00\u5B9A\u8303\u56F4\u5185\u8F93\u5165\u3001\u8C03\u6574\u6570\u5B57\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-stepper": "@vant/weapp/stepper/index"
-}
-
\u901A\u8FC7value
\u8BBE\u7F6E\u8F93\u5165\u503C\uFF0C\u53EF\u4EE5\u901A\u8FC7change
\u4E8B\u4EF6\u76D1\u542C\u5230\u8F93\u5165\u503C\u7684\u53D8\u5316\u3002
<van-stepper value="{{ 1 }}" bind:change="onChange" />
-
Page({
- onChange(event) {
- console.log(event.detail);
- },
-});
-
\u901A\u8FC7step
\u5C5E\u6027\u8BBE\u7F6E\u6BCF\u6B21\u70B9\u51FB\u589E\u52A0\u6216\u51CF\u5C11\u6309\u94AE\u65F6\u53D8\u5316\u7684\u503C\uFF0C\u9ED8\u8BA4\u4E3A1
\u3002
<van-stepper value="{{ 1 }}" step="2" />
-
\u901A\u8FC7min
\u548Cmax
\u5C5E\u6027\u9650\u5236\u8F93\u5165\u503C\u7684\u8303\u56F4\u3002
<van-stepper value="{{ 5 }}" min="5" max="8" />
-
\u8BBE\u7F6Einteger
\u5C5E\u6027\u540E\uFF0C\u8F93\u5165\u6846\u5C06\u9650\u5236\u53EA\u80FD\u8F93\u5165\u6574\u6570\u3002
<van-stepper value="{{ 1 }}" integer />
-
\u901A\u8FC7\u8BBE\u7F6Edisabled
\u5C5E\u6027\u6765\u7981\u7528\u6B65\u8FDB\u5668\uFF0C\u7981\u7528\u72B6\u6001\u4E0B\u65E0\u6CD5\u70B9\u51FB\u6309\u94AE\u6216\u4FEE\u6539\u8F93\u5165\u6846\u3002
<van-stepper value="{{ 1 }}" disabled />
-
\u901A\u8FC7\u8BBE\u7F6Elong-press
\u5C5E\u6027\u51B3\u5B9A\u6B65\u8FDB\u5668\u662F\u5426\u5F00\u542F\u957F\u6309\u624B\u52BF\u3002
<van-stepper value="{{ 1 }}" long-press="{{ false }}" />
-
\u901A\u8FC7\u8BBE\u7F6Edecimal-length
\u5C5E\u6027\u53EF\u4EE5\u4FDD\u7559\u56FA\u5B9A\u7684\u5C0F\u6570\u4F4D\u6570\u3002
<van-stepper value="{{ 1 }}" step="0.2" decimal-length="{{ 1 }}" />
-
\u5982\u679C\u9700\u8981\u5F02\u6B65\u5730\u4FEE\u6539\u8F93\u5165\u6846\u7684\u503C\uFF0C\u53EF\u4EE5\u8BBE\u7F6Easync-change
\u5C5E\u6027\uFF0C\u5E76\u5728change
\u4E8B\u4EF6\u4E2D\u624B\u52A8\u4FEE\u6539value
\u3002
<van-stepper value="{{ value }}" async-change bind:change="onChange" />
-
Page({
- data: {
- value: 1,
- },
-
- onChange(value) {
- Toast.loading({ forbidClick: true });
-
- setTimeout(() => {
- Toast.clear();
- this.setData({ value });
- }, 500);
- },
-});
-
\u901A\u8FC7input-width
\u5C5E\u6027\u8BBE\u7F6E\u8F93\u5165\u6846\u5BBD\u5EA6\uFF0C\u901A\u8FC7button-size
\u5C5E\u6027\u8BBE\u7F6E\u6309\u94AE\u5927\u5C0F\u548C\u8F93\u5165\u6846\u9AD8\u5EA6\u3002
<van-stepper value="{{ 1 }}" input-width="40px" button-size="32px" />
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
value | \u8F93\u5165\u503C | string | number | \u6700\u5C0F\u503C |
min | \u6700\u5C0F\u503C | string | number | 1 |
max | \u6700\u5927\u503C | string | number | - |
step | \u6B65\u957F | string | number | 1 |
integer | \u662F\u5426\u53EA\u5141\u8BB8\u8F93\u5165\u6574\u6570 | boolean | false |
disabled | \u662F\u5426\u7981\u7528 | boolean | false |
disable-input | \u662F\u5426\u7981\u7528\u8F93\u5165\u6846 | boolean | false |
async-change | \u662F\u5426\u5F00\u542F\u5F02\u6B65\u53D8\u66F4\uFF0C\u5F00\u542F\u540E\u9700\u8981\u624B\u52A8\u63A7\u5236\u8F93\u5165\u503C | boolean | false |
input-width | \u8F93\u5165\u6846\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | string | number | 32px |
button-size | \u6309\u94AE\u5927\u5C0F\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px \uFF0C\u8F93\u5165\u6846\u9AD8\u5EA6\u4F1A\u548C\u6309\u94AE\u5927\u5C0F\u4FDD\u6301\u4E00\u81F4 | string | number | 28px |
show-plus | \u662F\u5426\u663E\u793A\u589E\u52A0\u6309\u94AE | boolean | true |
show-minus | \u662F\u5426\u663E\u793A\u51CF\u5C11\u6309\u94AE | boolean | true |
decimal-length | \u56FA\u5B9A\u663E\u793A\u7684\u5C0F\u6570\u4F4D\u6570 | number | - |
theme | \u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3A round | string | - |
disable-plus | \u662F\u5426\u7981\u7528\u589E\u52A0\u6309\u94AE | boolean | - |
disable-minus | \u662F\u5426\u7981\u7528\u51CF\u5C11\u6309\u94AE | boolean | - |
long-press | \u662F\u5426\u5F00\u542F\u957F\u6309\u624B\u52BF | boolean | true |
always-embed v1.9.3 | \u5F3A\u5236 input \u5904\u4E8E\u540C\u5C42\u72B6\u6001\uFF0C\u9ED8\u8BA4 focus \u65F6 input \u4F1A\u5207\u5230\u975E\u540C\u5C42\u72B6\u6001 (\u4EC5\u5728 iOS \u4E0B\u751F\u6548) | boolean | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:change | \u5F53\u7ED1\u5B9A\u503C\u53D8\u5316\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | event.detail: \u5F53\u524D\u8F93\u5165\u7684\u503C |
bind:overlimit | \u70B9\u51FB\u4E0D\u53EF\u7528\u7684\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:plus | \u70B9\u51FB\u589E\u52A0\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:minus | \u70B9\u51FB\u51CF\u5C11\u6309\u94AE\u65F6\u89E6\u53D1 | - |
bind:focus | \u8F93\u5165\u6846\u805A\u7126\u65F6\u89E6\u53D1 | - |
bind:blur | \u8F93\u5165\u6846\u5931\u7126\u65F6\u89E6\u53D1 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
plus | \u52A0\u53F7\u6309\u94AE |
minus | \u51CF\u53F7\u6309\u94AE |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
input-class | \u8F93\u5165\u6846\u6837\u5F0F\u7C7B |
plus-class | \u52A0\u53F7\u6309\u94AE\u6837\u5F0F\u7C7B |
minus-class | \u51CF\u53F7\u6309\u94AE\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5C55\u793A\u64CD\u4F5C\u6D41\u7A0B\u7684\u5404\u4E2A\u73AF\u8282\uFF0C\u8BA9\u7528\u6237\u4E86\u89E3\u5F53\u524D\u7684\u64CD\u4F5C\u5728\u6574\u4F53\u6D41\u7A0B\u4E2D\u7684\u4F4D\u7F6E\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-steps": "@vant/weapp/steps/index"
-}
-
<van-steps steps="{{ steps }}" active="{{ active }}" />
-
Page({
- data: {
- steps: [
- {
- text: '\u6B65\u9AA4\u4E00',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- },
- {
- text: '\u6B65\u9AA4\u4E8C',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- },
- {
- text: '\u6B65\u9AA4\u4E09',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- },
- {
- text: '\u6B65\u9AA4\u56DB',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- },
- ],
- },
-});
-
\u53EF\u4EE5\u901A\u8FC7 active-icon
\u548C active-color
\u5C5E\u6027\u8BBE\u7F6E\u6FC0\u6D3B\u72B6\u6001\u4E0B\u7684\u56FE\u6807\u548C\u989C\u8272\u3002
<van-steps
- steps="{{ steps }}"
- active="{{ active }}"
- active-icon="success"
- active-color="#38f"
-/>
-
\u53EF\u4EE5\u901A\u8FC7 inactiveIcon
\u548C activeIcon
\u5C5E\u6027\u5206\u522B\u8BBE\u7F6E\u6BCF\u4E00\u9879\u7684\u56FE\u6807\u3002
<van-steps steps="{{ steps }}" active="{{ active }}" />
-
Page({
- data: {
- steps: [
- {
- text: '\u6B65\u9AA4\u4E00',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- inactiveIcon: 'location-o',
- activeIcon: 'success',
- },
- {
- text: '\u6B65\u9AA4\u4E8C',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- inactiveIcon: 'like-o',
- activeIcon: 'plus',
- },
- {
- text: '\u6B65\u9AA4\u4E09',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- inactiveIcon: 'star-o',
- activeIcon: 'cross',
- },
- {
- text: '\u6B65\u9AA4\u56DB',
- desc: '\u63CF\u8FF0\u4FE1\u606F',
- inactiveIcon: 'phone-o',
- activeIcon: 'fail',
- },
- ],
- },
-});
-
\u53EF\u4EE5\u901A\u8FC7\u8BBE\u7F6Edirection
\u5C5E\u6027\u6765\u6539\u53D8\u6B65\u9AA4\u6761\u7684\u663E\u793A\u65B9\u5F0F\u3002
<van-steps
- steps="{{ steps }}"
- active="{{ active }}"
- direction="vertical"
- active-color="#ee0a24"
-/>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
active | \u5F53\u524D\u6B65\u9AA4 | number | 0 |
steps | \u6B65\u9AA4\u914D\u7F6E\u96C6\u5408\uFF0C\u89C1\u4E0B\u9762\u914D\u7F6E\u9879 | Step \u914D\u7F6E\u9879\u6570\u7EC4 | [] |
direction | \u663E\u793A\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A horizontal vertical | string | horizontal |
active-color | \u6FC0\u6D3B\u72B6\u6001\u989C\u8272 | string | #07c160 |
inactive-color | \u672A\u6FC0\u6D3B\u72B6\u6001\u989C\u8272 | string | #969799 |
active-icon | \u6FC0\u6D3B\u72B6\u6001\u5E95\u90E8\u56FE\u6807\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | checked |
inactive-icon | \u672A\u6FC0\u6D3B\u72B6\u6001\u5E95\u90E8\u56FE\u6807\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
\u4E8B\u4EF6\u540D\u79F0 | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:click-step | \u70B9\u51FB\u6B65\u9AA4\u65F6\u89E6\u53D1\u7684\u4E8B\u4EF6 | event.detail:\u5F53\u524D\u6B65\u9AA4\u7684\u7D22\u5F15 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
desc-class | \u63CF\u8FF0\u4FE1\u606F\u6837\u5F0F\u7C7B |
\u952E\u540D | \u8BF4\u660E | \u7C7B\u578B |
---|---|---|
text | \u5F53\u524D\u6B65\u9AA4\u540D\u79F0 | string |
desc | \u5F53\u524D\u6B65\u9AA4\u63CF\u8FF0\u4FE1\u606F | string |
activeIcon | \u5F53\u524D\u6B65\u9AA4\u6FC0\u6D3B\u72B6\u6001\u5E95\u90E8\u56FE\u6807 | string |
inactiveIcon | \u5F53\u524D\u6B65\u9AA4\u672A\u6FC0\u6D3B\u72B6\u6001\u5E95\u90E8\u56FE\u6807\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string |
Sticky \u7EC4\u4EF6\u4E0E CSS \u4E2Dposition: sticky
\u5C5E\u6027\u5B9E\u73B0\u7684\u6548\u679C\u4E00\u81F4\uFF0C\u5F53\u7EC4\u4EF6\u5728\u5C4F\u5E55\u8303\u56F4\u5185\u65F6\uFF0C\u4F1A\u6309\u7167\u6B63\u5E38\u7684\u5E03\u5C40\u6392\u5217\uFF0C\u5F53\u7EC4\u4EF6\u6EDA\u51FA\u5C4F\u5E55\u8303\u56F4\u65F6\uFF0C\u59CB\u7EC8\u4F1A\u56FA\u5B9A\u5728\u5C4F\u5E55\u9876\u90E8\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-sticky": "@vant/weapp/sticky/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u5C06\u5185\u5BB9\u5305\u88F9\u5728Sticky
\u7EC4\u4EF6\u5185\u5373\u53EF\u3002
<van-sticky>
- <van-button type="primary">\u57FA\u7840\u7528\u6CD5</van-button>
-</van-sticky>
-
\u901A\u8FC7offset-top
\u5C5E\u6027\u53EF\u4EE5\u8BBE\u7F6E\u7EC4\u4EF6\u5728\u5438\u9876\u65F6\u4E0E\u9876\u90E8\u7684\u8DDD\u79BB\u3002
<van-sticky offset-top="{{ 50 }}">
- <van-button type="info">\u5438\u9876\u8DDD\u79BB</van-button>
-</van-sticky>
-
\u901A\u8FC7container
\u5C5E\u6027\u53EF\u4EE5\u6307\u5B9A\u7EC4\u4EF6\u7684\u5BB9\u5668\uFF0C\u9875\u9762\u6EDA\u52A8\u65F6\uFF0C\u7EC4\u4EF6\u4F1A\u59CB\u7EC8\u4FDD\u6301\u5728\u5BB9\u5668\u8303\u56F4\u5185\uFF0C\u5F53\u7EC4\u4EF6\u5373\u5C06\u8D85\u51FA\u5BB9\u5668\u5E95\u90E8\u65F6\uFF0C\u4F1A\u8FD4\u56DE\u539F\u4F4D\u7F6E\u3002
<view id="container" style="height: 150px;">
- <van-sticky container="{{ container }}">
- <van-button type="warning">\u6307\u5B9A\u5BB9\u5668</van-button>
- </van-sticky>
-</view>
-
Page({
- data: {
- container: null,
- },
-
- onReady() {
- this.setData({
- container: () => wx.createSelectorQuery().select('#container'),
- });
- },
-});
-
\u901A\u8FC7 scroll-top
\u4E0E offset-top
\u5C5E\u6027\u53EF\u4EE5\u5B9E\u73B0\u5728 scroll-view \u5185\u5D4C\u5957\u4F7F\u7528\u3002
<scroll-view
- bind:scroll="onScroll"
- scroll-y
- id="scroller"
- style="height: 200px;"
->
- <view style="height: 400px; padding-top: 50px;">
- <van-sticky scroll-top="{{ scrollTop }}" offset-top="{{ offsetTop }}">
- <van-button type="warning">\u5D4C\u5957\u5728 scroll-view \u5185</van-button>
- </van-sticky>
- </view>
-</scroll-view>
-
Page({
- data: {
- scrollTop: 0,
- offsetTop: 0,
- },
-
- onScroll(event) {
- wx.createSelectorQuery()
- .select('#scroller')
- .boundingClientRect((res) => {
- this.setData({
- scrollTop: event.detail.scrollTop,
- offsetTop: res.top,
- });
- })
- .exec();
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
offset-top | \u5438\u9876\u65F6\u4E0E\u9876\u90E8\u7684\u8DDD\u79BB\uFF0C\u5355\u4F4Dpx | number | 0 |
z-index | \u5438\u9876\u65F6\u7684 z-index | number | 99 |
container | \u4E00\u4E2A\u51FD\u6570\uFF0C\u8FD4\u56DE\u5BB9\u5668\u5BF9\u5E94\u7684 NodesRef \u8282\u70B9 | function | - |
scroll-top | \u5F53\u524D\u6EDA\u52A8\u533A\u57DF\u7684\u6EDA\u52A8\u4F4D\u7F6E\uFF0C\u975E null \u65F6\u4F1A\u7981\u7528\u9875\u9762\u6EDA\u52A8\u4E8B\u4EF6\u7684\u76D1\u542C | number | - |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:scroll | \u6EDA\u52A8\u65F6\u89E6\u53D1 | { scrollTop: \u8DDD\u79BB\u9876\u90E8\u4F4D\u7F6E, isFixed: \u662F\u5426\u5438\u9876 } |
\u7528\u4E8E\u5C55\u793A\u8BA2\u5355\u91D1\u989D\u4E0E\u63D0\u4EA4\u8BA2\u5355\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-submit-bar": "@vant/weapp/submit-bar/index"
-}
-
<van-submit-bar
- price="{{ 3050 }}"
- button-text="\u63D0\u4EA4\u8BA2\u5355"
- bind:submit="onSubmit"
-/>
-
\u7981\u7528\u72B6\u6001\u4E0B\u4E0D\u4F1A\u89E6\u53D1submit
\u4E8B\u4EF6\u3002
<van-submit-bar
- disabled
- price="{{ 3050 }}"
- button-text="\u63D0\u4EA4\u8BA2\u5355"
- tip="\u60A8\u7684\u6536\u8D27\u5730\u5740\u4E0D\u652F\u6301\u540C\u57CE\u9001, \u6211\u4EEC\u5DF2\u4E3A\u60A8\u63A8\u8350\u5FEB\u9012"
- tip-icon="info-o"
- bind:submit="onSubmit"
-/>
-
\u52A0\u8F7D\u72B6\u6001\u4E0B\u4E0D\u4F1A\u89E6\u53D1submit
\u4E8B\u4EF6\u3002
<van-submit-bar
- loading
- price="{{ 3050 }}"
- button-text="\u63D0\u4EA4\u8BA2\u5355"
- bind:submit="onSubmit"
-/>
-
\u901A\u8FC7\u63D2\u69FD\u63D2\u5165\u81EA\u5B9A\u4E49\u5185\u5BB9\u3002
<van-submit-bar
- price="{{ 3050 }}"
- button-text="\u63D0\u4EA4\u8BA2\u5355"
- bind:submit="onClickButton"
- tip="{{ true }}"
->
- <van-tag type="primary">\u6807\u7B7E</van-tag>
- <view slot="tip">\u60A8\u7684\u6536\u8D27\u5730\u5740\u4E0D\u652F\u6301\u540C\u57CE\u9001, <text>\u4FEE\u6539\u5730\u5740</text></view>
-</van-submit-bar>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
price | \u4EF7\u683C\uFF08\u5355\u4F4D\u5206\uFF09 | number | - |
label | \u4EF7\u683C\u6587\u6848 | string | \u5408\u8BA1\uFF1A |
suffix-label | \u4EF7\u683C\u53F3\u4FA7\u6587\u6848 | string | - |
button-text | \u6309\u94AE\u6587\u5B57 | string | - |
button-type | \u6309\u94AE\u7C7B\u578B | string | danger |
tip | \u63D0\u793A\u6587\u6848 | string | boolean | - |
tip-icon | \u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
disabled | \u662F\u5426\u7981\u7528\u6309\u94AE | boolean | false |
loading | \u662F\u5426\u663E\u793A\u52A0\u8F7D\u4E2D\u7684\u6309\u94AE | boolean | false |
currency | \u8D27\u5E01\u7B26\u53F7 | string | \xA5 |
safe-area-inset-bottom | \u662F\u5426\u4E3A iPhoneX \u7559\u51FA\u5E95\u90E8\u5B89\u5168\u8DDD\u79BB | boolean | true |
decimal-length | \u4EF7\u683C\u5C0F\u6570\u70B9\u540E\u4F4D\u6570 | number | 2 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:submit | \u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6\u56DE\u8C03 | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u8BA2\u5355\u680F\u5DE6\u4FA7\u5185\u5BB9 |
top | \u81EA\u5B9A\u4E49\u8BA2\u5355\u680F\u4E0A\u65B9\u5185\u5BB9 |
tip | \u63D0\u793A\u6587\u6848\u4E2D\u7684\u989D\u5916\u64CD\u4F5C\u548C\u8BF4\u660E |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
price-class | \u4EF7\u683C\u6837\u5F0F\u7C7B |
button-class | \u6309\u94AE\u6837\u5F0F\u7C7B |
bar-class | \u8BA2\u5355\u680F\u6837\u5F0F\u7C7B |
\u53EF\u4EE5\u5DE6\u53F3\u6ED1\u52A8\u6765\u5C55\u793A\u64CD\u4F5C\u6309\u94AE\u7684\u5355\u5143\u683C\u7EC4\u4EF6\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-swipe-cell": "@vant/weapp/swipe-cell/index"
-}
-
<van-swipe-cell right-width="{{ 65 }}" left-width="{{ 65 }}">
- <view slot="left" class="van-swipe-cell__left">\u9009\u62E9</view>
- <van-cell-group>
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
- </van-cell-group>
- <view slot="right" class="van-swipe-cell__right">\u5220\u9664</view>
-</van-swipe-cell>
-
\u5F53\u5F00\u542Fasync-close
\u65F6\uFF0C \u901A\u8FC7\u7ED1\u5B9Aclose
\u4E8B\u4EF6\uFF0C\u53EF\u4EE5\u81EA\u5B9A\u4E49\u4E24\u4FA7\u6ED1\u52A8\u5185\u5BB9\u70B9\u51FB\u65F6\u7684\u5173\u95ED\u884C\u4E3A\u3002
<van-swipe-cell
- id="swipe-cell"
- right-width="{{ 65 }}"
- left-width="{{ 65 }}"
- async-close
- bind:close="onClose"
->
- <view slot="left">\u9009\u62E9</view>
- <van-cell-group>
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
- </van-cell-group>
- <view slot="right">\u5220\u9664</view>
-</van-swipe-cell>
-
Page({
- onClose(event) {
- const { position, instance } = event.detail;
- switch (position) {
- case 'left':
- case 'cell':
- instance.close();
- break;
- case 'right':
- Dialog.confirm({
- message: '\u786E\u5B9A\u5220\u9664\u5417\uFF1F',
- }).then(() => {
- instance.close();
- });
- break;
- }
- },
-});
-
<van-swipe-cell
- id="swipe-cell2"
- right-width="{{ 65 }}"
- left-width="{{ 65 }}"
- name="\u793A\u4F8B"
- bind:open="onOpen"
->
- <view slot="left" class="van-swipe-cell__left">\u9009\u62E9</view>
- <van-cell-group>
- <van-cell title="\u5355\u5143\u683C" value="\u5185\u5BB9" />
- </van-cell-group>
- <view slot="right" class="van-swipe-cell__right">\u5220\u9664</view>
-</van-swipe-cell>
-
Page({
- onOpen(event) {
- const { position, name } = event.detail;
- switch (position) {
- case 'left':
- Notify({
- type: 'primary',
- message: \`\${name}\${position}\u90E8\u5206\u5C55\u793Aopen\u4E8B\u4EF6\u88AB\u89E6\u53D1\`,
- });
- break;
- case 'right':
- Notify({
- type: 'primary',
- message: \`\${name}\${position}\u90E8\u5206\u5C55\u793Aopen\u4E8B\u4EF6\u88AB\u89E6\u53D1\`,
- });
- break;
- }
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u8BC6\u7B26\uFF0C\u53EF\u4EE5\u5728 close \u4E8B\u4EF6\u7684\u53C2\u6570\u4E2D\u83B7\u53D6\u5230 | string | number | - |
left-width | \u5DE6\u4FA7\u6ED1\u52A8\u533A\u57DF\u5BBD\u5EA6 | number | 0 |
right-width | \u53F3\u4FA7\u6ED1\u52A8\u533A\u57DF\u5BBD\u5EA6 | number | 0 |
async-close | \u662F\u5426\u5F02\u6B65\u5173\u95ED | boolean | false |
disabled v1.3.4 | \u662F\u5426\u7981\u7528\u6ED1\u52A8 | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u663E\u793A\u5185\u5BB9 |
left | \u5DE6\u4FA7\u6ED1\u52A8\u5185\u5BB9 |
right | \u53F3\u4FA7\u6ED1\u52A8\u5185\u5BB9 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u65F6\u89E6\u53D1 | \u5173\u95ED\u65F6\u7684\u70B9\u51FB\u4F4D\u7F6E (left right cell outside ) |
bind:close | \u5173\u95ED\u65F6\u89E6\u53D1 | { position: 'left' | 'right' , instance , name: string } |
bind:open | \u6253\u5F00\u65F6\u89E6\u53D1 | { position: 'left' | 'right' , name: string } |
\u53C2\u6570 | \u7C7B\u578B | \u8BF4\u660E |
---|---|---|
position | string | \u5173\u95ED\u65F6\u7684\u70B9\u51FB\u4F4D\u7F6E (left right cell outside ) |
instance | object | SwipeCell \u5B9E\u4F8B |
name | \u6807\u8BC6\u7B26 | string |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 SwipeCell \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
open | position: left | right | - | \u6253\u5F00\u5355\u5143\u683C\u4FA7\u8FB9\u680F |
close | - | - | \u6536\u8D77\u5355\u5143\u683C\u4FA7\u8FB9\u680F |
\u7528\u4E8E\u5728\u6253\u5F00\u548C\u5173\u95ED\u72B6\u6001\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-switch": "@vant/weapp/switch/index"
-}
-
<van-switch checked="{{ checked }}" bind:change="onChange" />
-
Page({
- data: {
- checked: true,
- },
-
- onChange({ detail }) {
- // \u9700\u8981\u624B\u52A8\u5BF9 checked \u72B6\u6001\u8FDB\u884C\u66F4\u65B0
- this.setData({ checked: detail });
- },
-});
-
<van-switch checked="{{ checked }}" disabled />
-
<van-switch checked="{{ checked }}" loading />
-
<van-switch checked="{{ checked }}" size="24px" />
-
<van-switch
- checked="{{ checked }}"
- active-color="#07c160"
- inactive-color="#ee0a24"
-/>
-
<van-switch checked="{{ checked }}" bind:change="onChange" />
-
Page({
- data: {
- checked: true,
- },
-
- onChange({ detail }) {
- wx.showModal({
- title: '\u63D0\u793A',
- content: '\u662F\u5426\u5207\u6362\u5F00\u5173\uFF1F',
- success: (res) => {
- if (res.confirm) {
- this.setData({ checked2: detail });
- }
- },
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u5728\u8868\u5355\u5185\u63D0\u4EA4\u65F6\u7684\u6807\u8BC6\u7B26 | string | - |
checked | \u5F00\u5173\u9009\u4E2D\u72B6\u6001 | any | false |
loading | \u662F\u5426\u4E3A\u52A0\u8F7D\u72B6\u6001 | boolean | false |
disabled | \u662F\u5426\u4E3A\u7981\u7528\u72B6\u6001 | boolean | false |
size | \u5F00\u5173\u5C3A\u5BF8 | string | 30px |
active-color | \u6253\u5F00\u65F6\u7684\u80CC\u666F\u8272 | string | #1989fa |
inactive-color | \u5173\u95ED\u65F6\u7684\u80CC\u666F\u8272 | string | #fff |
active-value | \u6253\u5F00\u65F6\u7684\u503C | any | true |
inactive-value | \u5173\u95ED\u65F6\u7684\u503C | any | false |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:change | \u5F00\u5173\u72B6\u6001\u5207\u6362\u56DE\u8C03 | event.detail: \u662F\u5426\u9009\u4E2D\u5F00\u5173 |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
node-class | \u5706\u70B9\u6837\u5F0F\u7C7B |
\u9009\u9879\u5361\u7EC4\u4EF6\uFF0C\u7528\u4E8E\u5728\u4E0D\u540C\u7684\u5185\u5BB9\u533A\u57DF\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-tab": "@vant/weapp/tab/index",
- "van-tabs": "@vant/weapp/tabs/index"
-}
-
\u901A\u8FC7active
\u8BBE\u5B9A\u5F53\u524D\u6FC0\u6D3B\u6807\u7B7E\u5BF9\u5E94\u7684\u7D22\u5F15\u503C\uFF0C\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u542F\u7528\u7B2C\u4E00\u4E2A\u6807\u7B7E\u3002
<van-tabs active="{{ active }}" bind:change="onChange">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
-</van-tabs>
-
Page({
- data: {
- active: 1,
- },
-
- onChange(event) {
- wx.showToast({
- title: \`\u5207\u6362\u5230\u6807\u7B7E \${event.detail.name}\`,
- icon: 'none',
- });
- },
-});
-
\u5728\u6807\u7B7E\u6307\u5B9Aname
\u5C5E\u6027\u7684\u60C5\u51B5\u4E0B\uFF0Cactive
\u7684\u503C\u4E3A\u5F53\u524D\u6807\u7B7E\u7684name
\uFF08\u6B64\u65F6\u65E0\u6CD5\u901A\u8FC7\u7D22\u5F15\u503C\u6765\u5339\u914D\u6807\u7B7E\uFF09\u3002
<van-tabs active="a">
- <van-tab title="\u6807\u7B7E 1" name="a">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2" name="b">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3" name="c">\u5185\u5BB9 3</van-tab>
-</van-tabs>
-
\u591A\u4E8E 5 \u4E2A\u6807\u7B7E\u65F6\uFF0CTab \u53EF\u4EE5\u6A2A\u5411\u6EDA\u52A8\u3002
<van-tabs active="{{ active }}">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
- <van-tab title="\u6807\u7B7E 5">\u5185\u5BB9 5</van-tab>
- <van-tab title="\u6807\u7B7E 6">\u5185\u5BB9 6</van-tab>
-</van-tabs>
-
\u8BBE\u7F6Edisabled
\u5C5E\u6027\u5373\u53EF\u7981\u7528\u6807\u7B7E\u3002\u5982\u679C\u9700\u8981\u76D1\u542C\u7981\u7528\u6807\u7B7E\u7684\u70B9\u51FB\u4E8B\u4EF6\uFF0C\u53EF\u4EE5\u5728van-tabs
\u4E0A\u76D1\u542Cdisabled
\u4E8B\u4EF6\u3002
<van-tabs bind:disabled="onClickDisabled">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2" disabled>\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
-</van-tabs>
-
Page({
- onClickDisabled(event) {
- wx.showToast({
- title: \`\u6807\u7B7E \${event.detail.name} \u5DF2\u88AB\u7981\u7528\`,
- icon: 'none',
- });
- },
-});
-
Tab
\u652F\u6301\u4E24\u79CD\u6837\u5F0F\u98CE\u683C\uFF1Aline
\u548Ccard
\uFF0C\u9ED8\u8BA4\u4E3Aline
\u6837\u5F0F\uFF0C\u53EF\u4EE5\u901A\u8FC7type
\u5C5E\u6027\u4FEE\u6539\u6837\u5F0F\u98CE\u683C\u3002
<van-tabs type="card">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
-</van-tabs>
-
\u53EF\u4EE5\u5728van-tabs
\u4E0A\u7ED1\u5B9Aclick
\u4E8B\u4EF6\uFF0C\u5728\u56DE\u8C03\u53C2\u6570\u7684event.detail
\u4E2D\u53EF\u4EE5\u53D6\u5F97\u88AB\u70B9\u51FB\u6807\u7B7E\u7684\u6807\u9898\u548C\u6807\u8BC6\u7B26\u3002
<van-tabs bind:click="onClick">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
-</van-tabs>
-
Page({
- onClick(event) {
- wx.showToast({
- title: \`\u70B9\u51FB\u6807\u7B7E \${event.detail.name}\`,
- icon: 'none',
- });
- },
-});
-
\u901A\u8FC7sticky
\u5C5E\u6027\u53EF\u4EE5\u5F00\u542F\u7C98\u6027\u5E03\u5C40\uFF0C\u7C98\u6027\u5E03\u5C40\u4E0B\uFF0C\u5F53 Tab \u6EDA\u52A8\u5230\u9876\u90E8\u65F6\u4F1A\u81EA\u52A8\u5438\u9876\u3002
<van-tabs sticky>
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
-</van-tabs>
-
\u53EF\u4EE5\u901A\u8FC7animated
\u6765\u8BBE\u7F6E\u662F\u5426\u542F\u7528\u5207\u6362 tab \u65F6\u7684\u52A8\u753B\u3002
<van-tabs animated>
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
-</van-tabs>
-
\u901A\u8FC7swipeable
\u5C5E\u6027\u53EF\u4EE5\u5F00\u542F\u6ED1\u52A8\u5207\u6362\u6807\u7B7E\u9875\u3002
<van-tabs swipeable>
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
-</van-tabs>
-
\u5982\u679C\u5C06 van-tabs \u5D4C\u5957\u5728 van-popup \u7B49\u4F1A\u9690\u85CF\u5185\u5BB9\u7684\u7EC4\u4EF6\u6216\u8282\u70B9\u5185\uFF0C\u5F53 van-tabs \u663E\u793A\u65F6\u4E0B\u5212\u7EBF\u5C06\u4E0D\u4F1A\u6B63\u5E38\u663E\u793A\u3002
\u6B64\u65F6\u53EF\u4EE5\u901A\u8FC7\u4F7F\u7528 wx:if
\u624B\u52A8\u63A7\u5236 van-tabs \u7684\u6E32\u67D3\u6765\u89C4\u907F\u8FD9\u79CD\u573A\u666F\u3002
<van-popup show="{{ show }}">
- <van-tabs wx:if="{{ show }}">
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
- </van-tabs>
-</van-popup>
-
\u901A\u8FC7 before-change
\u4E8B\u4EF6\u53EF\u4EE5\u5728\u5207\u6362\u6807\u7B7E\u524D\u6267\u884C\u7279\u5B9A\u7684\u903B\u8F91\uFF0C\u5B9E\u73B0\u5207\u6362\u524D\u6821\u9A8C\u3001\u5F02\u6B65\u5207\u6362\u7684\u76EE\u7684
<van-tabs active="{{ active }}" use-before-change="{{ true }}" bind:change="onChange" bind:before-change="onBeforeChange" >
- <van-tab title="\u6807\u7B7E 1">\u5185\u5BB9 1</van-tab>
- <van-tab title="\u6807\u7B7E 2">\u5185\u5BB9 2</van-tab>
- <van-tab title="\u6807\u7B7E 3">\u5185\u5BB9 3</van-tab>
- <van-tab title="\u6807\u7B7E 4">\u5185\u5BB9 4</van-tab>
-</van-tabs>
-
Page({
- data: {
- active: 1,
- },
-
- onChange(event) {
- wx.showToast({
- title: \`\u5207\u6362\u5230\u6807\u7B7E \${event.detail.name}\`,
- icon: 'none',
- });
- },
- onBeforeChange(event) {
- const { callback, title } = event.detail;
-
- wx.showModal({
- title: '\u5F02\u6B65\u5207\u6362',
- content: \`\u786E\u5B9A\u8981\u5207\u6362\u81F3 \${title} tab\u5417\uFF1F\`,
- success: (res) => {
- if (res.confirm) {
- callback(true)
- } else if (res.cancel) {
- callback(false)
- }
- },
- })
- }
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
type | \u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3Acard | string | line |
color | \u6807\u7B7E\u4E3B\u9898\u8272 | string | #ee0a24 |
active | \u5F53\u524D\u9009\u4E2D\u6807\u7B7E\u7684\u6807\u8BC6\u7B26 | string | number | 0 |
duration | \u52A8\u753B\u65F6\u95F4\uFF0C\u5355\u4F4D\u79D2 | number | 0.3 |
line-width | \u5E95\u90E8\u6761\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4Dpx | string | number | 40px |
line-height | \u5E95\u90E8\u6761\u9AD8\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4Dpx | string | number | 3px |
animated | \u662F\u5426\u5F00\u542F\u5207\u6362\u6807\u7B7E\u5185\u5BB9\u65F6\u7684\u8F6C\u573A\u52A8\u753B | boolean | false |
border | \u662F\u5426\u5C55\u793A\u5916\u8FB9\u6846\uFF0C\u4EC5\u5728 line \u98CE\u683C\u4E0B\u751F\u6548 | boolean | false |
ellipsis | \u662F\u5426\u7701\u7565\u8FC7\u957F\u7684\u6807\u9898\u6587\u5B57 | boolean | true |
sticky | \u662F\u5426\u4F7F\u7528\u7C98\u6027\u5B9A\u4F4D\u5E03\u5C40 | boolean | false |
swipeable | \u662F\u5426\u5F00\u542F\u624B\u52BF\u6ED1\u52A8\u5207\u6362 | boolean | false |
lazy-render | \u662F\u5426\u5F00\u542F\u6807\u7B7E\u9875\u5185\u5BB9\u5EF6\u8FDF\u6E32\u67D3 | boolean | true |
offset-top | \u7C98\u6027\u5B9A\u4F4D\u5E03\u5C40\u4E0B\u4E0E\u9876\u90E8\u7684\u6700\u5C0F\u8DDD\u79BB\uFF0C\u5355\u4F4Dpx | number | - |
swipe-threshold | \u6EDA\u52A8\u9608\u503C\uFF0C\u6807\u7B7E\u6570\u91CF\u8D85\u8FC7\u9608\u503C\u4E14\u603B\u5BBD\u5EA6\u8D85\u8FC7\u6807\u7B7E\u680F\u5BBD\u5EA6\u65F6\u5F00\u59CB\u6A2A\u5411\u6EDA\u52A8 | number | 5 |
title-active-color | \u6807\u9898\u9009\u4E2D\u6001\u989C\u8272 | string | - |
title-inactive-color | \u6807\u9898\u9ED8\u8BA4\u6001\u989C\u8272 | string | - |
z-index | z-index \u5C42\u7EA7 | number | 1 |
use-before-change v1.10.10 | \u662F\u5426\u5F00\u542F\u5207\u6362\u524D\u6821\u9A8C | boolean | false |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u7B7E\u540D\u79F0\uFF0C\u4F5C\u4E3A\u5339\u914D\u7684\u6807\u8BC6\u7B26 | string | number | \u6807\u7B7E\u7684\u7D22\u5F15\u503C |
title | \u6807\u9898 | string | - |
disabled | \u662F\u5426\u7981\u7528\u6807\u7B7E | boolean | false |
dot | \u662F\u5426\u663E\u793A\u5C0F\u7EA2\u70B9 | boolean | - |
info | \u56FE\u6807\u53F3\u4E0A\u89D2\u63D0\u793A\u4FE1\u606F | string | number | - |
title-style | \u81EA\u5B9A\u4E49\u6807\u9898\u6837\u5F0F | string | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
nav-left | \u6807\u9898\u5DE6\u4FA7\u5185\u5BB9 |
nav-right | \u6807\u9898\u53F3\u4FA7\u5185\u5BB9 |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u6807\u7B7E\u9875\u5185\u5BB9 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:click | \u70B9\u51FB\u6807\u7B7E\u65F6\u89E6\u53D1 | name\uFF1A\u6807\u7B7E\u6807\u8BC6\u7B26\uFF0Ctitle\uFF1A\u6807\u9898 |
bind:before-change v1.10.10 | tab \u5207\u6362\u524D\u4F1A\u89E6\u53D1\uFF0C\u5728\u56DE\u8C03\u51FD\u6570\u4E2D\u8FD4\u56DE false \u53EF\u7EC8\u6B62 tab \u5207\u6362\uFF0C\u7ED1\u5B9A\u4E8B\u4EF6\u7684\u540C\u65F6\u9700\u8981\u5C06use-before-change \u5C5E\u6027\u8BBE\u7F6E\u4E3Atrue | event.detail.name : \u5F53\u524D\u5207\u6362\u7684 tab \u6807\u8BC6\u7B26\uFF0C event.detail.title : \u5F53\u524D\u5207\u6362\u7684 tab \u6807\u9898\uFF0C event.detail.index : \u5F53\u524D\u5207\u6362\u7684 tab \u4E0B\u6807\uFF0Cevent.detail.callback : \u56DE\u8C03\u51FD\u6570\uFF0C\u8C03\u7528callback(false) \u7EC8\u6B62 tab \u5207\u6362 |
bind:change | \u5F53\u524D\u6FC0\u6D3B\u7684\u6807\u7B7E\u6539\u53D8\u65F6\u89E6\u53D1 | name\uFF1A\u6807\u7B7E\u6807\u8BC6\u7B26\uFF0Ctitle\uFF1A\u6807\u9898 |
bind:disabled | \u70B9\u51FB\u88AB\u7981\u7528\u7684\u6807\u7B7E\u65F6\u89E6\u53D1 | name\uFF1A\u6807\u7B7E\u6807\u8BC6\u7B26\uFF0Ctitle\uFF1A\u6807\u9898 |
bind:scroll | \u6EDA\u52A8\u65F6\u89E6\u53D1 | { scrollTop: \u8DDD\u79BB\u9876\u90E8\u4F4D\u7F6E, isFixed: \u662F\u5426\u5438\u9876 } |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
nav-class | \u6807\u7B7E\u680F\u6837\u5F0F\u7C7B |
tab-class | \u6807\u7B7E\u6837\u5F0F\u7C7B |
tab-active-class | \u6807\u7B7E\u6FC0\u6D3B\u6001\u6837\u5F0F\u7C7B |
wrap-class | \u6807\u7B7E\u680F\u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u901A\u8FC7 selectComponent \u53EF\u4EE5\u83B7\u53D6\u5230 Tabs \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\u3002
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
resize | - | - | \u5916\u5C42\u5143\u7D20\u5927\u5C0F\u6216\u7EC4\u4EF6\u663E\u793A\u72B6\u6001\u53D8\u5316\u65F6\uFF0C\u53EF\u4EE5\u8C03\u7528\u6B64\u65B9\u6CD5\u6765\u89E6\u53D1\u91CD\u7ED8 |
Tabs \u7EC4\u4EF6\u5728\u6302\u8F7D\u65F6\uFF0C\u4F1A\u83B7\u53D6\u81EA\u8EAB\u7684\u5BBD\u5EA6\uFF0C\u5E76\u8BA1\u7B97\u51FA\u5E95\u90E8\u6761\u7684\u4F4D\u7F6E\u3002\u5982\u679C\u7EC4\u4EF6\u4E00\u5F00\u59CB\u5904\u4E8E\u9690\u85CF\u72B6\u6001\uFF0C\u5219\u83B7\u53D6\u5230\u7684\u5BBD\u5EA6\u6C38\u8FDC\u4E3A 0\uFF0C\u56E0\u6B64\u65E0\u6CD5\u5C55\u793A\u5E95\u90E8\u6761\u4F4D\u7F6E\u3002
\u65B9\u6CD5\u4E00\uFF0C\u4F7F\u7528 wx:if
\u6765\u63A7\u5236\u7EC4\u4EF6\u5C55\u793A\uFF0C\u4F7F\u7EC4\u4EF6\u91CD\u65B0\u521D\u59CB\u5316\u3002
<van-tabs wx:if="show" />
-
\u65B9\u6CD5\u4E8C\uFF0C\u8C03\u7528\u7EC4\u4EF6\u7684 resize \u65B9\u6CD5\u6765\u4E3B\u52A8\u89E6\u53D1\u91CD\u7ED8\u3002
<van-tabs id="tabs" />
-
this.selectComponent('#tabs').resize();
-
\u5E95\u90E8\u5BFC\u822A\u680F\uFF0C\u7528\u4E8E\u5728\u4E0D\u540C\u9875\u9762\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-tabbar": "@vant/weapp/tabbar/index",
- "van-tabbar-item": "@vant/weapp/tabbar-item/index"
-}
-
<van-tabbar active="{{ active }}" bind:change="onChange">
- <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="search">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="friends-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>
-</van-tabbar>
-
Page({
- data: {
- active: 0,
- },
- onChange(event) {
- // event.detail \u7684\u503C\u4E3A\u5F53\u524D\u9009\u4E2D\u9879\u7684\u7D22\u5F15
- this.setData({ active: event.detail });
- },
-});
-
\u5728\u6807\u7B7E\u6307\u5B9Aname
\u5C5E\u6027\u7684\u60C5\u51B5\u4E0B\uFF0Cv-model
\u7684\u503C\u4E3A\u5F53\u524D\u6807\u7B7E\u7684name
\u3002
<van-tabbar active="{{ active }}" bind:change="onChange">
- <van-tabbar-item name="home" icon="home-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item name="search" icon="search">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item name="friends" icon="friends-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item name="setting" icon="setting-o">\u6807\u7B7E</van-tabbar-item>
-</van-tabbar>
-
Page({
- data: {
- active: 'home',
- },
- onChange(event) {
- this.setData({ active: event.detail });
- },
-});
-
<van-tabbar active="{{ active }}" bind:change="onChange">
- <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="search" dot>\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="friends-o" info="5">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="setting-o" info="20">\u6807\u7B7E</van-tabbar-item>
-</van-tabbar>
-
\u53EF\u4EE5\u901A\u8FC7 slot \u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u5176\u4E2D icon slot \u4EE3\u8868\u672A\u9009\u4E2D\u72B6\u6001\u4E0B\u7684\u56FE\u6807\uFF0Cicon-active slot \u4EE3\u8868\u9009\u4E2D\u72B6\u6001\u4E0B\u7684\u56FE\u6807\u3002
<van-tabbar active="{{ active }}" bind:change="onChange">
- <van-tabbar-item info="3">
- <image
- slot="icon"
- src="{{ icon.normal }}"
- mode="aspectFit"
- style="width: 30px; height: 18px;"
- />
- <image
- slot="icon-active"
- src="{{ icon.active }}"
- mode="aspectFit"
- style="width: 30px; height: 18px;"
- />
- \u81EA\u5B9A\u4E49
- </van-tabbar-item>
- <van-tabbar-item icon="search">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>
-</van-tabbar>
-
Page({
- data: {
- active: 0,
- icon: {
- normal: 'https://img.yzcdn.cn/vant/user-inactive.png',
- active: 'https://img.yzcdn.cn/vant/user-active.png',
- },
- },
- onChange(event) {
- this.setData({ active: event.detail });
- },
-});
-
<van-tabbar
- active="{{ active }}"
- active-color="#07c160"
- inactive-color="#000"
- bind:change="onChange"
->
- <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="search">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="friends-o">\u6807\u7B7E</van-tabbar-item>
- <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>
-</van-tabbar>
-
Page({
- data: {
- active: 0,
- },
- onChange(event) {
- this.setData({ active: event.detail });
- },
-});
-
<van-tabbar active="{{ active }}" bind:change="onChange">
- <van-tabbar-item icon="home-o">\u6807\u7B7E1</van-tabbar-item>
- <van-tabbar-item icon="search">\u6807\u7B7E2</van-tabbar-item>
- <van-tabbar-item icon="friends-o">\u6807\u7B7E3</van-tabbar-item>
- <van-tabbar-item icon="setting-o">\u6807\u7B7E4</van-tabbar-item>
-</van-tabbar>
-
Page({
- data: {
- active: 0,
- },
- onClick(event) {
- wx.showToast({
- title: \`\u70B9\u51FB\u6807\u7B7E \${event.detail + 1}\`,
- icon: 'none',
- });
- },
-});
-
\u8BF7\u53C2\u8003 \u5FAE\u4FE1\u5B98\u65B9\u6587\u6863 \u4E0E \u4EE3\u7801\u7247\u6BB5\u3002
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
active | \u5F53\u524D\u9009\u4E2D\u6807\u7B7E\u7684\u7D22\u5F15 | number | - |
fixed | \u662F\u5426\u56FA\u5B9A\u5728\u5E95\u90E8 | boolean | true |
placeholder | \u56FA\u5B9A\u5728\u5E95\u90E8\u65F6\uFF0C\u662F\u5426\u5728\u6807\u7B7E\u4F4D\u7F6E\u751F\u6210\u4E00\u4E2A\u7B49\u9AD8\u7684\u5360\u4F4D\u5143\u7D20 | boolean | false |
border | \u662F\u5426\u5C55\u793A\u5916\u8FB9\u6846 | boolean | true |
z-index | \u5143\u7D20 z-index | number | 1 |
active-color | \u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272 | string | #1989fa |
inactive-color | \u672A\u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272 | string | #7d7e80 |
safe-area-inset-bottom | \u662F\u5426\u4E3A iPhoneX \u7559\u51FA\u5E95\u90E8\u5B89\u5168\u8DDD\u79BB | boolean | true |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:change | \u5207\u6362\u6807\u7B7E\u65F6\u89E6\u53D1 | event.detail: \u5F53\u524D\u9009\u4E2D\u6807\u7B7E\u7684\u540D\u79F0\u6216\u7D22\u5F15\u503C |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u7B7E\u540D\u79F0\uFF0C\u4F5C\u4E3A\u5339\u914D\u7684\u6807\u8BC6\u7B26 | string | number | \u5F53\u524D\u6807\u7B7E\u7684\u7D22\u5F15\u503C |
icon | \u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | - |
icon-prefix | \u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u540C Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027 | string | van-icon |
dot | \u662F\u5426\u663E\u793A\u5C0F\u7EA2\u70B9 | boolean | - |
info | \u56FE\u6807\u53F3\u4E0A\u89D2\u63D0\u793A\u4FE1\u606F | string | number | - |
url v1.10.13 | \u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740, \u9700\u8981\u4EE5 / \u5F00\u5934 | string | - |
link-type v1.10.13 | \u94FE\u63A5\u8DF3\u8F6C\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A redirectTo \u3001switchTab \u3001reLaunch | string | redirectTo |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
icon | \u672A\u9009\u4E2D\u65F6\u7684\u56FE\u6807 |
icon-active | \u9009\u4E2D\u65F6\u7684\u56FE\u6807 |
\u7528\u4E8E\u6807\u8BB0\u5173\u952E\u8BCD\u548C\u6982\u62EC\u4E3B\u8981\u5185\u5BB9\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-tag": "@vant/weapp/tag/index"
-}
-
\u901A\u8FC7 type
\u5C5E\u6027\u63A7\u5236\u6807\u7B7E\u989C\u8272\uFF0C\u9ED8\u8BA4\u4E3A\u7070\u8272\u3002
<van-tag type="primary">\u6807\u7B7E</van-tag>
-<van-tag type="success">\u6807\u7B7E</van-tag>
-<van-tag type="danger">\u6807\u7B7E</van-tag>
-<van-tag type="warning">\u6807\u7B7E</van-tag>
-
\u8BBE\u7F6E plain
\u5C5E\u6027\u8BBE\u7F6E\u4E3A\u7A7A\u5FC3\u6837\u5F0F\u3002
<van-tag plain type="primary">\u6807\u7B7E</van-tag>
-<van-tag plain type="success">\u6807\u7B7E</van-tag>
-<van-tag plain type="danger">\u6807\u7B7E</van-tag>
-<van-tag plain type="warning">\u6807\u7B7E</van-tag>
-
\u901A\u8FC7 round
\u8BBE\u7F6E\u4E3A\u5706\u89D2\u6837\u5F0F\u3002
<van-tag round type="primary">\u6807\u7B7E</van-tag>
-<van-tag round type="success">\u6807\u7B7E</van-tag>
-<van-tag round type="danger">\u6807\u7B7E</van-tag>
-<van-tag round type="warning">\u6807\u7B7E</van-tag>
-
\u901A\u8FC7 mark
\u8BBE\u7F6E\u4E3A\u6807\u8BB0\u6837\u5F0F(\u534A\u5706\u89D2)\u3002
<van-tag mark type="primary">\u6807\u7B7E</van-tag>
-<van-tag mark type="success">\u6807\u7B7E</van-tag>
-<van-tag mark type="danger">\u6807\u7B7E</van-tag>
-<van-tag mark type="warning">\u6807\u7B7E</van-tag>
-
<van-tag color="#f2826a">\u6807\u7B7E</van-tag>
-<van-tag color="#7232dd">\u6807\u7B7E</van-tag>
-<van-tag color="#7232dd" plain>\u6807\u7B7E</van-tag>
-<van-tag color="#ffe1e1" text-color="#ad0000">\u6807\u7B7E</van-tag>
-
<van-tag type="danger">\u6807\u7B7E</van-tag>
-<van-tag type="danger" size="medium">\u6807\u7B7E</van-tag>
-<van-tag type="danger" size="large">\u6807\u7B7E</van-tag>
-
\u6DFB\u52A0 closeable
\u5C5E\u6027\u8868\u793A\u6807\u7B7E\u662F\u53EF\u5173\u95ED\u7684\uFF0C\u5173\u95ED\u6807\u7B7E\u65F6\u4F1A\u89E6\u53D1 close
\u4E8B\u4EF6\uFF0C\u5728 close
\u4E8B\u4EF6\u4E2D\u53EF\u4EE5\u6267\u884C\u9690\u85CF\u6807\u7B7E\u7684\u903B\u8F91\u3002
<van-tag
- wx:if="{{ show.primary }}"
- closeable
- size="medium"
- type="primary"
- id="primary"
- bind:close="onClose"
->
- \u6807\u7B7E
-</van-tag>
-<van-tag
- wx:if="{{ show.success }}"
- closeable
- size="medium"
- type="success"
- id="success"
- bind:close="onClose"
->
- \u6807\u7B7E
-</van-tag>
-
Page({
- data: {
- show: {
- primary: true,
- success: true,
- },
- },
- onClose(event) {
- this.setData({
- [\`show.\${event.target.id}\`]: false,
- });
- },
-});
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
type | \u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary success danger warning | string | - |
size | \u5927\u5C0F, \u53EF\u9009\u503C\u4E3A large medium | string | - |
color | \u6807\u7B7E\u989C\u8272 | string | - |
plain | \u662F\u5426\u4E3A\u7A7A\u5FC3\u6837\u5F0F | boolean | false |
round | \u662F\u5426\u4E3A\u5706\u89D2\u6837\u5F0F | boolean | false |
mark | \u662F\u5426\u4E3A\u6807\u8BB0\u6837\u5F0F | boolean | false |
text-color | \u6587\u672C\u989C\u8272\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E color \u5C5E\u6027 | string | white |
closeable | \u662F\u5426\u4E3A\u53EF\u5173\u95ED\u6807\u7B7E | boolean | false |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49 Tag \u663E\u793A\u5185\u5BB9 |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:close | \u5173\u95ED\u6807\u7B7E\u65F6\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
\u5728\u9875\u9762\u4E2D\u95F4\u5F39\u51FA\u9ED1\u8272\u534A\u900F\u660E\u63D0\u793A\uFF0C\u7528\u4E8E\u6D88\u606F\u901A\u77E5\u3001\u52A0\u8F7D\u63D0\u793A\u3001\u64CD\u4F5C\u7ED3\u679C\u63D0\u793A\u7B49\u573A\u666F\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-toast": "@vant/weapp/toast/index"
-}
-
import Toast from '@vant/weapp/toast/toast';
-
-Toast('\u6211\u662F\u63D0\u793A\u6587\u6848\uFF0C\u5EFA\u8BAE\u4E0D\u8D85\u8FC7\u5341\u4E94\u5B57~');
-
<van-toast id="van-toast" />
-
\u4F7F\u7528 Toast.loading
\u65B9\u6CD5\u5C55\u793A\u52A0\u8F7D\u63D0\u793A\uFF0C\u901A\u8FC7 forbidClick
\u5C5E\u6027\u53EF\u4EE5\u7981\u7528\u80CC\u666F\u70B9\u51FB\uFF0C\u901A\u8FC7 loadingType
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u52A0\u8F7D\u56FE\u6807\u7C7B\u578B\u3002
Toast.loading({
- message: '\u52A0\u8F7D\u4E2D...',
- forbidClick: true,
-});
-
-// \u81EA\u5B9A\u4E49\u52A0\u8F7D\u56FE\u6807
-Toast.loading({
- message: '\u52A0\u8F7D\u4E2D...',
- forbidClick: true,
- loadingType: 'spinner',
-});
-
Toast.success('\u6210\u529F\u6587\u6848');
-Toast.fail('\u5931\u8D25\u6587\u6848');
-
const toast = Toast.loading({
- duration: 0, // \u6301\u7EED\u5C55\u793A toast
- forbidClick: true,
- message: '\u5012\u8BA1\u65F6 3 \u79D2',
- selector: '#custom-selector',
-});
-
-let second = 3;
-const timer = setInterval(() => {
- second--;
- if (second) {
- toast.setData({
- message: \`\u5012\u8BA1\u65F6 \${second} \u79D2\`,
- });
- } else {
- clearInterval(timer);
- Toast.clear();
- }
-}, 1000);
-
<van-toast id="custom-selector" />
-
Toast({
- type: 'success',
- message: '\u63D0\u4EA4\u6210\u529F',
- onClose: () => {
- console.log('\u6267\u884COnClose\u51FD\u6570');
- },
-});
-
\u65B9\u6CD5\u540D | \u53C2\u6570 | \u8FD4\u56DE\u503C | \u4ECB\u7ECD |
---|---|---|---|
Toast | options | message | toast \u5B9E\u4F8B | \u5C55\u793A\u63D0\u793A |
Toast.loading | options | message | toast \u5B9E\u4F8B | \u5C55\u793A\u52A0\u8F7D\u63D0\u793A |
Toast.success | options | message | toast \u5B9E\u4F8B | \u5C55\u793A\u6210\u529F\u63D0\u793A |
Toast.fail | options | message | toast \u5B9E\u4F8B | \u5C55\u793A\u5931\u8D25\u63D0\u793A |
Toast.clear | clearAll | void | \u5173\u95ED\u63D0\u793A |
Toast.setDefaultOptions | options | void | \u4FEE\u6539\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5BF9\u6240\u6709 Toast \u751F\u6548 |
Toast.resetDefaultOptions | - | void | \u91CD\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5BF9\u6240\u6709 Toast \u751F\u6548 |
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
type | \u63D0\u793A\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A loading success fail html | string | text |
position | \u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top middle bottom | string | middle |
message | \u5185\u5BB9 | string | '' |
mask | \u662F\u5426\u663E\u793A\u906E\u7F69\u5C42 | boolean | false |
forbidClick | \u662F\u5426\u7981\u6B62\u80CC\u666F\u70B9\u51FB | boolean | false |
loadingType | \u52A0\u8F7D\u56FE\u6807\u7C7B\u578B, \u53EF\u9009\u503C\u4E3A spinner | string | circular |
zIndex | z-index \u5C42\u7EA7 | number | 1000 |
duration | \u5C55\u793A\u65F6\u957F(ms)\uFF0C\u503C\u4E3A 0 \u65F6\uFF0Ctoast \u4E0D\u4F1A\u6D88\u5931 | number | 2000 |
selector | \u81EA\u5B9A\u4E49\u9009\u62E9\u5668 | string | van-toast |
context | \u9009\u62E9\u5668\u7684\u9009\u62E9\u8303\u56F4\uFF0C\u53EF\u4EE5\u4F20\u5165\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u7684 this \u4F5C\u4E3A\u4E0A\u4E0B\u6587 | object | \u5F53\u524D\u9875\u9762 |
onClose | \u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570 | Function | - |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u5185\u5BB9 |
\u4F7F\u5143\u7D20\u4ECE\u4E00\u79CD\u6837\u5F0F\u9010\u6E10\u53D8\u5316\u4E3A\u53E6\u4E00\u79CD\u6837\u5F0F\u7684\u6548\u679C\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-transition": "@vant/weapp/transition/index"
-}
-
\u5C06\u5143\u7D20\u5305\u88F9\u5728 transition \u7EC4\u4EF6\u5185\uFF0C\u5728\u5143\u7D20\u5C55\u793A/\u9690\u85CF\u65F6\uFF0C\u4F1A\u6709\u76F8\u5E94\u7684\u8FC7\u6E21\u52A8\u753B\u3002
<van-transition show="{{ show }}" custom-class="block">\u5185\u5BB9</van-transition>
-
transition \u7EC4\u4EF6\u5185\u7F6E\u4E86\u591A\u79CD\u52A8\u753B\uFF0C\u53EF\u4EE5\u901A\u8FC7name
\u5B57\u6BB5\u6307\u5B9A\u52A8\u753B\u7C7B\u578B\u3002
<van-transition name="fade-up" />
-
\u53EF\u4EE5\u901A\u8FC7\u5916\u90E8\u6837\u5F0F\u7C7B\u81EA\u5B9A\u4E49\u8FC7\u6E21\u6548\u679C\uFF0C\u8FD8\u53EF\u4EE5\u5B9A\u5236\u8FDB\u5165\u548C\u79FB\u51FA\u7684\u6301\u7EED\u65F6\u95F4\u3002
<van-transition
- show="{{ show }}"
- name=""
- duration="{{ { enter: 300, leave: 1000 } }}"
- enter-class="van-enter-class"
- enter-active-class="van-enter-active-class"
- leave-active-class="van-leave-active-class"
- leave-to-class="van-leave-to-class"
-/>
-
.van-enter-active-class,
-.van-leave-active-class {
- transition-property: background-color, transform;
-}
-
-.van-enter-class,
-.van-leave-to-class {
- background-color: red;
- transform: rotate(-360deg) translate3d(-100%, -100%, 0);
-}
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u52A8\u753B\u7C7B\u578B | string | fade |
show | \u662F\u5426\u5C55\u793A\u7EC4\u4EF6 | boolean | true |
duration | \u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2 | number | object | 300 |
custom-style | \u81EA\u5B9A\u4E49\u6837\u5F0F | string | - |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u53C2\u6570 |
---|---|---|
bind:before-enter | \u8FDB\u5165\u524D\u89E6\u53D1 | - |
bind:enter | \u8FDB\u5165\u4E2D\u89E6\u53D1 | - |
bind:after-enter | \u8FDB\u5165\u540E\u89E6\u53D1 | - |
bind:before-leave | \u79BB\u5F00\u524D\u89E6\u53D1 | - |
bind:leave | \u79BB\u5F00\u4E2D\u89E6\u53D1 | - |
bind:after-leave | \u79BB\u5F00\u540E\u89E6\u53D1 | - |
\u7C7B\u540D | \u8BF4\u660E |
---|---|
custom-class | \u6839\u8282\u70B9\u6837\u5F0F\u7C7B |
enter-class | \u5B9A\u4E49\u8FDB\u5165\u8FC7\u6E21\u7684\u5F00\u59CB\u72B6\u6001\u3002\u5728\u5143\u7D20\u88AB\u63D2\u5165\u4E4B\u524D\u751F\u6548\uFF0C\u5728\u5143\u7D20\u88AB\u63D2\u5165\u4E4B\u540E\u7684\u4E0B\u4E00\u5E27\u79FB\u9664\u3002 |
enter-active-class | \u5B9A\u4E49\u8FDB\u5165\u8FC7\u6E21\u751F\u6548\u65F6\u7684\u72B6\u6001\u3002\u5728\u6574\u4E2A\u8FDB\u5165\u8FC7\u6E21\u7684\u9636\u6BB5\u4E2D\u5E94\u7528\uFF0C\u5728\u5143\u7D20\u88AB\u63D2\u5165\u4E4B\u524D\u751F\u6548\uFF0C\u5728\u8FC7\u6E21/\u52A8\u753B\u5B8C\u6210\u4E4B\u540E\u79FB\u9664\u3002\u8FD9\u4E2A\u7C7B\u53EF\u4EE5\u88AB\u7528\u6765\u5B9A\u4E49\u8FDB\u5165\u8FC7\u6E21\u7684\u8FC7\u7A0B\u65F6\u95F4\uFF0C\u5EF6\u8FDF\u548C\u66F2\u7EBF\u51FD\u6570\u3002 |
enter-to-class | \u5B9A\u4E49\u8FDB\u5165\u8FC7\u6E21\u7684\u7ED3\u675F\u72B6\u6001\u3002\u5728\u5143\u7D20\u88AB\u63D2\u5165\u4E4B\u540E\u4E0B\u4E00\u5E27\u751F\u6548 (\u4E0E\u6B64\u540C\u65F6 enter-class \u88AB\u79FB\u9664)\uFF0C\u5728\u8FC7\u6E21/\u52A8\u753B\u5B8C\u6210\u4E4B\u540E\u79FB\u9664\u3002 |
leave-class | \u5B9A\u4E49\u79BB\u5F00\u8FC7\u6E21\u7684\u5F00\u59CB\u72B6\u6001\u3002\u5728\u79BB\u5F00\u8FC7\u6E21\u88AB\u89E6\u53D1\u65F6\u7ACB\u523B\u751F\u6548\uFF0C\u4E0B\u4E00\u5E27\u88AB\u79FB\u9664\u3002 |
leave-active-class | \u5B9A\u4E49\u79BB\u5F00\u8FC7\u6E21\u751F\u6548\u65F6\u7684\u72B6\u6001\u3002\u5728\u6574\u4E2A\u79BB\u5F00\u8FC7\u6E21\u7684\u9636\u6BB5\u4E2D\u5E94\u7528\uFF0C\u5728\u79BB\u5F00\u8FC7\u6E21\u88AB\u89E6\u53D1\u65F6\u7ACB\u523B\u751F\u6548\uFF0C\u5728\u8FC7\u6E21/\u52A8\u753B\u5B8C\u6210\u4E4B\u540E\u79FB\u9664\u3002\u8FD9\u4E2A\u7C7B\u53EF\u4EE5\u88AB\u7528\u6765\u5B9A\u4E49\u79BB\u5F00\u8FC7\u6E21\u7684\u8FC7\u7A0B\u65F6\u95F4\uFF0C\u5EF6\u8FDF\u548C\u66F2\u7EBF\u51FD\u6570\u3002 |
leave-to-class | \u5B9A\u4E49\u79BB\u5F00\u8FC7\u6E21\u7684\u7ED3\u675F\u72B6\u6001\u3002\u5728\u79BB\u5F00\u8FC7\u6E21\u88AB\u89E6\u53D1\u4E4B\u540E\u4E0B\u4E00\u5E27\u751F\u6548 (\u4E0E\u6B64\u540C\u65F6 leave-class \u88AB\u5220\u9664)\uFF0C\u5728\u8FC7\u6E21/\u52A8\u753B\u5B8C\u6210\u4E4B\u540E\u79FB\u9664\u3002 |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
fade | \u6DE1\u5165 |
fade-up | \u4E0A\u6ED1\u6DE1\u5165 |
fade-down | \u4E0B\u6ED1\u6DE1\u5165 |
fade-left | \u5DE6\u6ED1\u6DE1\u5165 |
fade-right | \u53F3\u6ED1\u6DE1\u5165 |
slide-up | \u4E0A\u6ED1\u8FDB\u5165 |
slide-down | \u4E0B\u6ED1\u8FDB\u5165 |
slide-left | \u5DE6\u6ED1\u8FDB\u5165 |
slide-right | \u53F3\u6ED1\u8FDB\u5165 |
\u7528\u4E8E\u4ECE\u4E00\u7EC4\u76F8\u5173\u8054\u7684\u6570\u636E\u96C6\u5408\u4E2D\u8FDB\u884C\u9009\u62E9\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u8BE6\u7EC6\u4ECB\u7ECD\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-tree-select": "@vant/weapp/tree-select/index"
-}
-
\u53EF\u4EE5\u5728\u4EFB\u610F\u4F4D\u7F6E\u4E0A\u4F7F\u7528 van-tree-select \u6807\u7B7E\u3002\u4F20\u5165\u5BF9\u5E94\u7684\u6570\u636E\u5373\u53EF\u3002\u6B64\u7EC4\u4EF6\u652F\u6301\u5355\u9009\u6216\u591A\u9009\uFF0C\u5177\u4F53\u884C\u4E3A\u5B8C\u5168\u57FA\u4E8E\u4E8B\u4EF6 click-item \u7684\u5B9E\u73B0\u903B\u8F91\u5982\u4F55\u4E3A\u5C5E\u6027 active-id \u8D4B\u503C\uFF0C\u5F53 active-id \u4E3A\u6570\u7EC4\u65F6\u5373\u4E3A\u591A\u9009\u72B6\u6001\u3002
<van-tree-select
- items="{{ items }}"
- main-active-index="{{ mainActiveIndex }}"
- active-id="{{ activeId }}"
- bind:click-nav="onClickNav"
- bind:click-item="onClickItem"
-/>
-
Page({
- data: {
- mainActiveIndex: 0,
- activeId: null,
- },
-
- onClickNav({ detail = {} }) {
- this.setData({
- mainActiveIndex: detail.index || 0,
- });
- },
-
- onClickItem({ detail = {} }) {
- const activeId = this.data.activeId === detail.id ? null : detail.id;
-
- this.setData({ activeId });
- },
-});
-
<van-tree-select
- items="{{ items }}"
- main-active-index="{{ mainActiveIndex }}"
- active-id="{{ activeId }}"
- max="{{ max }}"
- bind:click-nav="onClickNav"
- bind:click-item="onClickItem"
-/>
-
Page({
- data: {
- mainActiveIndex: 0,
- activeId: [],
- max: 2,
- },
-
- onClickNav({ detail = {} }) {
- this.setData({
- mainActiveIndex: detail.index || 0,
- });
- },
-
- onClickItem({ detail = {} }) {
- const { activeId } = this.data;
-
- const index = activeId.indexOf(detail.id);
- if (index > -1) {
- activeId.splice(index, 1);
- } else {
- activeId.push(detail.id);
- }
-
- this.setData({ activeId });
- },
-});
-
<van-tree-select
- items="{{ items }}"
- height="55vw"
- main-active-index="{{ mainActiveIndex }}"
- active-id="{{ activeId }}"
- bind:click-nav="onClickNav"
- bind:click-item="onClickItem"
->
- <image src="https://img.yzcdn.cn/vant/apple-1.jpg" slot="content" />
-</van-tree-select>
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
items | \u5206\u7C7B\u663E\u793A\u6240\u9700\u7684\u6570\u636E | Array | [] |
height | \u9AD8\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | number | string | 300 |
main-active-index | \u5DE6\u4FA7\u9009\u4E2D\u9879\u7684\u7D22\u5F15 | number | 0 |
active-id | \u53F3\u4FA7\u9009\u4E2D\u9879\u7684 id\uFF0C\u652F\u6301\u4F20\u5165\u6570\u7EC4 | string | number | Array | 0 |
max | \u53F3\u4FA7\u9879\u6700\u5927\u9009\u4E2D\u4E2A\u6570 | number | Infinity |
selected-icon v1.5.0 | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u680F\u9009\u4E2D\u72B6\u6001\u7684\u56FE\u6807 | string | success |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:click-nav | \u5DE6\u4FA7\u5BFC\u822A\u70B9\u51FB\u65F6\uFF0C\u89E6\u53D1\u7684\u4E8B\u4EF6 | event.detail.index\uFF1A\u88AB\u70B9\u51FB\u7684\u5BFC\u822A\u7684\u7D22\u5F15 |
bind:click-item | \u53F3\u4FA7\u9009\u62E9\u9879\u88AB\u70B9\u51FB\u65F6\uFF0C\u4F1A\u89E6\u53D1\u7684\u4E8B\u4EF6 | event.detail: \u8BE5\u70B9\u51FB\u9879\u7684\u6570\u636E |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
content | \u81EA\u5B9A\u4E49\u53F3\u4FA7\u533A\u57DF\u5185\u5BB9\uFF0C\u5982\u679C\u5B58\u5728 items\uFF0C\u5219\u63D2\u5165\u5728\u9876\u90E8 |
items
\u6574\u4F53\u4E3A\u4E00\u4E2A\u6570\u7EC4\uFF0C\u6570\u7EC4\u5185\u5305\u542B\u4E00\u7CFB\u5217\u63CF\u8FF0\u5206\u7C7B\u7684\u5BF9\u8C61\u3002\u6BCF\u4E2A\u5206\u7C7B\u91CC\uFF0Ctext \u8868\u793A\u5F53\u524D\u5206\u7C7B\u7684\u540D\u79F0\u3002children \u8868\u793A\u5206\u7C7B\u91CC\u7684\u53EF\u9009\u9879\uFF0C\u4E3A\u6570\u7EC4\u7ED3\u6784\uFF0Cid \u88AB\u7528\u6765\u552F\u4E00\u6807\u8BC6\u6BCF\u4E2A\u9009\u9879\u3002
[
- {
- // \u5BFC\u822A\u540D\u79F0
- text: '\u6240\u6709\u57CE\u5E02',
- // \u5BFC\u822A\u540D\u79F0\u53F3\u4E0A\u89D2\u5FBD\u6807\uFF0C1.5.0 \u7248\u672C\u5F00\u59CB\u652F\u6301
- badge: 3,
- // \u662F\u5426\u5728\u5BFC\u822A\u540D\u79F0\u53F3\u4E0A\u89D2\u663E\u793A\u5C0F\u7EA2\u70B9\uFF0C1.5.0 \u7248\u672C\u5F00\u59CB\u652F\u6301
- dot: true,
- // \u7981\u7528\u9009\u9879
- disabled: false,
- // \u8BE5\u5BFC\u822A\u4E0B\u6240\u6709\u7684\u53EF\u9009\u9879
- children: [
- {
- // \u540D\u79F0
- text: '\u6E29\u5DDE',
- // id\uFF0C\u4F5C\u4E3A\u5339\u914D\u9009\u4E2D\u72B6\u6001\u7684\u6807\u8BC6
- id: 1,
- // \u7981\u7528\u9009\u9879
- disabled: true,
- },
- {
- text: '\u676D\u5DDE',
- id: 2,
- },
- ],
- },
-];
-
\u7C7B\u540D | \u8BF4\u660E |
---|---|
main-item-class | \u5DE6\u4FA7\u9009\u9879\u6837\u5F0F\u7C7B |
content-item-class | \u53F3\u4FA7\u9009\u9879\u6837\u5F0F\u7C7B |
main-active-class | \u5DE6\u4FA7\u9009\u9879\u9009\u4E2D\u6837\u5F0F\u7C7B |
content-active-class | \u53F3\u4FA7\u9009\u9879\u9009\u4E2D\u6837\u5F0F\u7C7B |
main-disabled-class | \u5DE6\u4FA7\u9009\u9879\u7981\u7528\u6837\u5F0F\u7C7B |
content-disabled-class | \u53F3\u4FA7\u9009\u9879\u7981\u7528\u6837\u5F0F\u7C7B |
\u7528\u4E8E\u5C06\u672C\u5730\u7684\u56FE\u7247\u6216\u6587\u4EF6\u4E0A\u4F20\u81F3\u670D\u52A1\u5668\uFF0C\u5E76\u5728\u4E0A\u4F20\u8FC7\u7A0B\u4E2D\u5C55\u793A\u9884\u89C8\u56FE\u548C\u4E0A\u4F20\u8FDB\u5EA6\u3002\u76EE\u524D Uploader \u7EC4\u4EF6\u4E0D\u5305\u542B\u5C06\u6587\u4EF6\u4E0A\u4F20\u81F3\u670D\u52A1\u5668\u7684\u63A5\u53E3\u903B\u8F91\uFF0C\u8BE5\u6B65\u9AA4\u9700\u8981\u81EA\u884C\u5B9E\u73B0\u3002
\u5728app.json
\u6216index.json
\u4E2D\u5F15\u5165\u7EC4\u4EF6\uFF0C\u9ED8\u8BA4\u4E3AES6
\u7248\u672C\uFF0CES5
\u5F15\u5165\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B\u3002
"usingComponents": {
- "van-uploader": "@vant/weapp/uploader/index"
-}
-
Vant Weapp 1.0 \u7248\u672C\u5F00\u59CB\u652F\u6301\u6B64\u7EC4\u4EF6\uFF0C\u5347\u7EA7\u65B9\u5F0F\u53C2\u89C1\u5FEB\u901F\u4E0A\u624B
\u6587\u4EF6\u4E0A\u4F20\u5B8C\u6BD5\u540E\u4F1A\u89E6\u53D1after-read
\u56DE\u8C03\u51FD\u6570\uFF0C\u83B7\u53D6\u5230\u5BF9\u5E94\u7684\u6587\u4EF6\u7684\u4E34\u65F6\u5730\u5740\uFF0C\u7136\u540E\u518D\u4F7F\u7528wx.uploadFile
\u5C06\u56FE\u7247\u4E0A\u4F20\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0A\u3002
<van-uploader file-list="{{ fileList }}" bind:after-read="afterRead" />
-
Page({
- data: {
- fileList: [],
- },
-
- afterRead(event) {
- const { file } = event.detail;
- // \u5F53\u8BBE\u7F6E mutiple \u4E3A true \u65F6, file \u4E3A\u6570\u7EC4\u683C\u5F0F\uFF0C\u5426\u5219\u4E3A\u5BF9\u8C61\u683C\u5F0F
- wx.uploadFile({
- url: 'https://example.weixin.qq.com/upload', // \u4EC5\u4E3A\u793A\u4F8B\uFF0C\u975E\u771F\u5B9E\u7684\u63A5\u53E3\u5730\u5740
- filePath: file.url,
- name: 'file',
- formData: { user: 'test' },
- success(res) {
- // \u4E0A\u4F20\u5B8C\u6210\u9700\u8981\u66F4\u65B0 fileList
- const { fileList = [] } = this.data;
- fileList.push({ ...file, url: res.data });
- this.setData({ fileList });
- },
- });
- },
-});
-
\u901A\u8FC7\u5411\u7EC4\u4EF6\u4F20\u5165file-list
\u5C5E\u6027\uFF0C\u53EF\u4EE5\u7ED1\u5B9A\u5DF2\u7ECF\u4E0A\u4F20\u7684\u56FE\u7247\u5217\u8868\uFF0C\u5E76\u5C55\u793A\u56FE\u7247\u5217\u8868\u7684\u9884\u89C8\u56FE\u3002file-list \u7684\u8BE6\u7EC6\u7ED3\u6784\u53EF\u89C1\u4E0B\u65B9\u3002
<van-uploader file-list="{{ fileList }}" />
-
Page({
- data: {
- fileList: [
- {
- url: 'https://img.yzcdn.cn/vant/leaf.jpg',
- name: '\u56FE\u72471',
- },
- // Uploader \u6839\u636E\u6587\u4EF6\u540E\u7F00\u6765\u5224\u65AD\u662F\u5426\u4E3A\u56FE\u7247\u6587\u4EF6
- // \u5982\u679C\u56FE\u7247 URL \u4E2D\u4E0D\u5305\u542B\u7C7B\u578B\u4FE1\u606F\uFF0C\u53EF\u4EE5\u6DFB\u52A0 isImage \u6807\u8BB0\u6765\u58F0\u660E
- {
- url: 'http://iph.href.lu/60x60?text=default',
- name: '\u56FE\u72472',
- isImage: true,
- deletable: true,
- },
- ],
- },
-});
-
\u901A\u8FC7deletable
\u5C5E\u6027\u53EF\u63A7\u5236\u662F\u5426\u5F00\u542F\u6240\u6709\u56FE\u7247\u7684\u53EF\u5220\u9664\u72B6\u6001\uFF0Cdeletable
\u9ED8\u8BA4\u4E3Atrue
\uFF0C\u5373\u6240\u6709\u56FE\u7247\u90FD\u53EF\u5220\u9664\u3002
\u82E5\u5E0C\u671B\u63A7\u5236\u5355\u5F20\u56FE\u7247\u7684\u53EF\u5220\u9664\u72B6\u6001\uFF0C\u53EF\u5C06deletable
\u5C5E\u6027\u8BBE\u7F6E\u4E3Atrue
\uFF0C\u5E76\u5728fileList
\u4E2D\u4E3A\u6BCF\u4E00\u9879\u8BBE\u7F6Edeletable
\u5C5E\u6027\u3002
<van-uploader file-list="{{ fileList }}" deletable="{{ true }}" />
-
Page({
- data: {
- fileList: [
- {
- url: 'https://img.yzcdn.cn/vant/leaf.jpg',
- },
- {
- url: 'https://img.yzcdn.cn/vant/tree.jpg',
- deletable: false,
- },
- ],
- },
-});
-
\u901A\u8FC7status
\u5C5E\u6027\u53EF\u4EE5\u6807\u8BC6\u4E0A\u4F20\u72B6\u6001\uFF0Cuploading
\u8868\u793A\u4E0A\u4F20\u4E2D\uFF0Cfailed
\u8868\u793A\u4E0A\u4F20\u5931\u8D25\uFF0Cdone
\u8868\u793A\u4E0A\u4F20\u5B8C\u6210\u3002
<van-uploader file-list="{{ fileList }}" />
-
Page({
- data: {
- fileList: [
- {
- url: 'https://img.yzcdn.cn/vant/leaf.jpg',
- status: 'uploading',
- message: '\u4E0A\u4F20\u4E2D',
- },
- {
- url: 'https://img.yzcdn.cn/vant/tree.jpg',
- status: 'failed',
- message: '\u4E0A\u4F20\u5931\u8D25',
- },
- ],
- },
-});
-
\u901A\u8FC7max-count
\u5C5E\u6027\u53EF\u4EE5\u9650\u5236\u4E0A\u4F20\u6587\u4EF6\u7684\u6570\u91CF\uFF0C\u4E0A\u4F20\u6570\u91CF\u8FBE\u5230\u9650\u5236\u540E\uFF0C\u4F1A\u81EA\u52A8\u9690\u85CF\u4E0A\u4F20\u533A\u57DF\u3002
<van-uploader
- file-list="{{ fileList }}"
- max-count="2"
- bind:after-read="afterRead"
-/>
-
\u901A\u8FC7\u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u4E0A\u4F20\u533A\u57DF\u7684\u6837\u5F0F\u3002
<van-uploader>
- <van-button icon="photo" type="primary">\u4E0A\u4F20\u56FE\u7247</van-button>
-</van-uploader>
-
\u5C06use-before-read
\u5C5E\u6027\u8BBE\u7F6E\u4E3Atrue
\uFF0C\u7136\u540E\u7ED1\u5B9A before-read
\u4E8B\u4EF6\u53EF\u4EE5\u5728\u4E0A\u4F20\u524D\u8FDB\u884C\u6821\u9A8C\uFF0C\u8C03\u7528 callback
\u65B9\u6CD5\u4F20\u5165 true
\u8868\u793A\u6821\u9A8C\u901A\u8FC7\uFF0C\u4F20\u5165 false
\u8868\u793A\u6821\u9A8C\u5931\u8D25\u3002
<van-uploader
- file-list="{{ fileList }}"
- accept="media"
- use-before-read
- bind:before-read="beforeRead"
- bind:after-read="afterRead"
-/>
-
Page({
- data: {
- fileList: [],
- },
-
- beforeRead(event) {
- const { file, callback } = event.detail;
- callback(file.type === 'image');
- },
-});
-
\u5728\u5F00\u53D1\u4E2D\uFF0C\u53EF\u4EE5\u5229\u7528\u5C0F\u7A0B\u5E8F\u4E91\u5F00\u53D1\u7684\u4E91\u5B58\u50A8\u80FD\u529B\uFF0C\u5C06\u56FE\u7247\u4E0A\u4F20\u81F3\u4E91\u5B58\u50A8\u5185\u3002\u7136\u540E\u6839\u636E\u8FD4\u56DE\u7684fileiId
\u6765\u4E0B\u8F7D\u56FE\u7247\u3001\u5220\u9664\u56FE\u7247\u548C\u66FF\u6362\u4E34\u65F6\u94FE\u63A5\u3002
// \u4E0A\u4F20\u56FE\u7247
-uploadToCloud() {
- wx.cloud.init();
- const { fileList } = this.data;
- if (!fileList.length) {
- wx.showToast({ title: '\u8BF7\u9009\u62E9\u56FE\u7247', icon: 'none' });
- } else {
- const uploadTasks = fileList.map((file, index) => this.uploadFilePromise(\`my-photo\${index}.png\`, file));
- Promise.all(uploadTasks)
- .then(data => {
- wx.showToast({ title: '\u4E0A\u4F20\u6210\u529F', icon: 'none' });
- const newFileList = data.map(item => ({ url: item.fileID }));
- this.setData({ cloudPath: data, fileList: newFileList });
- })
- .catch(e => {
- wx.showToast({ title: '\u4E0A\u4F20\u5931\u8D25', icon: 'none' });
- console.log(e);
- });
- }
-}
-
-uploadFilePromise(fileName, chooseResult) {
- return wx.cloud.uploadFile({
- cloudPath: fileName,
- filePath: chooseResult.url
- });
-}
-
\u53C2\u6570 | \u8BF4\u660E | \u7C7B\u578B | \u9ED8\u8BA4\u503C |
---|---|---|---|
name | \u6807\u8BC6\u7B26\uFF0C\u53EF\u4EE5\u5728\u56DE\u8C03\u51FD\u6570\u7684\u7B2C\u4E8C\u9879\u53C2\u6570\u4E2D\u83B7\u53D6 | string | number | - |
accept | \u63A5\u53D7\u7684\u6587\u4EF6\u7C7B\u578B, \u53EF\u9009\u503C\u4E3Aall media image file video | string | image |
sizeType | \u6240\u9009\u7684\u56FE\u7247\u7684\u5C3A\u5BF8, \u5F53accept \u4E3Aimage | media \u7C7B\u578B\u65F6\u8BBE\u7F6E\u6240\u9009\u56FE\u7247\u7684\u5C3A\u5BF8\u53EF\u9009\u503C\u4E3Aoriginal compressed | string[] | ['original','compressed'] |
preview-size | \u9884\u89C8\u56FE\u548C\u4E0A\u4F20\u533A\u57DF\u7684\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3Apx | string | number | 80px |
preview-image | \u662F\u5426\u5728\u4E0A\u4F20\u5B8C\u6210\u540E\u5C55\u793A\u9884\u89C8\u56FE | boolean | true |
preview-full-image | \u662F\u5426\u5728\u70B9\u51FB\u9884\u89C8\u56FE\u540E\u5C55\u793A\u5168\u5C4F\u56FE\u7247\u9884\u89C8 | boolean | true |
multiple | \u662F\u5426\u5F00\u542F\u56FE\u7247\u591A\u9009\uFF0C\u90E8\u5206\u5B89\u5353\u673A\u578B\u4E0D\u652F\u6301 | boolean | false |
disabled | \u662F\u5426\u7981\u7528\u6587\u4EF6\u4E0A\u4F20 | boolean | false |
show-upload | \u662F\u5426\u5C55\u793A\u6587\u4EF6\u4E0A\u4F20\u6309\u94AE | boolean | true |
deletable | \u662F\u5426\u5C55\u793A\u5220\u9664\u6309\u94AE | boolean | true |
capture | \u56FE\u7247\u6216\u8005\u89C6\u9891\u9009\u53D6\u6A21\u5F0F\uFF0C\u5F53accept \u4E3Aimage | media \u7C7B\u578B\u65F6\u8BBE\u7F6Ecapture \u53EF\u9009\u503C\u4E3Acamera \u53EF\u4EE5\u76F4\u63A5\u8C03\u8D77\u6444\u50CF\u5934 | string[] | ['album', 'camera'] |
max-size | \u6587\u4EF6\u5927\u5C0F\u9650\u5236\uFF0C\u5355\u4F4D\u4E3Abyte | number | - |
max-count | \u6587\u4EF6\u4E0A\u4F20\u6570\u91CF\u9650\u5236 | number | - |
upload-text | \u4E0A\u4F20\u533A\u57DF\u6587\u5B57\u63D0\u793A | string | - |
video-fit 1.10.21 | video \u5C01\u9762\u7684\u9884\u89C8\u56FE\u6A21\u5F0F\uFF0C\u53EF\u9009\u503C\u53C2\u8003\u5C0F\u7A0B\u5E8Fvideo \u7EC4\u4EF6\u7684object-fit \u5C5E\u6027 | string | contain |
image-fit | \u9884\u89C8\u56FE\u88C1\u526A\u6A21\u5F0F\uFF0C\u53EF\u9009\u503C\u53C2\u8003\u5C0F\u7A0B\u5E8Fimage \u7EC4\u4EF6\u7684mode \u5C5E\u6027 | string | scaleToFill |
use-before-read | \u662F\u5426\u5F00\u542F\u6587\u4EF6\u8BFB\u53D6\u524D\u4E8B\u4EF6 | boolean | - |
camera | \u5F53 accept \u4E3A video | media \u65F6\u751F\u6548\uFF0C\u53EF\u9009\u503C\u4E3A back front | string | - |
compressed | \u5F53 accept \u4E3A video \u65F6\u751F\u6548\uFF0C\u662F\u5426\u538B\u7F29\u89C6\u9891\uFF0C\u9ED8\u8BA4\u4E3Atrue | boolean | - |
max-duration | \u5F53 accept \u4E3A video | media \u65F6\u751F\u6548\uFF0C\u62CD\u6444\u89C6\u9891\u6700\u957F\u62CD\u6444\u65F6\u95F4\uFF0C\u5355\u4F4D\u79D2 | number | 60 |
media-type v1.10.8 | \u5F53 accept \u4E3A media \u65F6\u751F\u6548\uFF0C\u9009\u62E9\u7684\u6587\u4EF6\u7684\u6587\u4EF6\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A image video | string[] | ['image', 'video'] |
extension v1.10.11 | \u5F53 accept \u4E3A file \u65F6\u751F\u6548\uFF0C\u6839\u636E\u6587\u4EF6\u62D3\u5C55\u540D\u8FC7\u6EE4\u53EF\u9009\u62E9\u6587\u4EF6\u3002\u6BCF\u4E00\u9879\u90FD\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002\u9ED8\u8BA4\u4E0D\u8FC7\u6EE4 | string[] | undefined | - |
showmenu v1.10.13 | \u9884\u89C8\u56FE\u7247\u65F6\uFF0C\u662F\u5426\u663E\u793A\u957F\u6309\u83DC\u5355 | boolean | true |
upload-icon | \u4E0A\u4F20\u533A\u57DF\u56FE\u6807\uFF0C\u53EF\u9009\u503C\u89C1 Icon \u7EC4\u4EF6 | string | plus |
\u53C2\u6570 | \u8BF4\u660E |
---|---|
media | \u56FE\u7247\u548C\u89C6\u9891 |
image | \u56FE\u7247 |
video | \u89C6\u9891 |
file | \u4ECE\u5BA2\u6237\u7AEF\u4F1A\u8BDD\u9009\u62E9\u56FE\u7247\u548C\u89C6\u9891\u4EE5\u5916\u7684\u6587\u4EF6 |
all | \u4ECE\u5BA2\u6237\u7AEF\u4F1A\u8BDD\u9009\u62E9\u6240\u6709\u6587\u4EF6 |
file-list
\u4E3A\u4E00\u4E2A\u5BF9\u8C61\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E00\u4E2A\u5BF9\u8C61\u5305\u542B\u4EE5\u4E0B key
\u3002
\u53C2\u6570 | \u8BF4\u660E |
---|---|
url | \u56FE\u7247\u548C\u89C6\u9891\u7684\u7F51\u7EDC\u8D44\u6E90\u5730\u5740 |
name | \u6587\u4EF6\u540D\u79F0\uFF0C\u89C6\u9891\u5C06\u5728\u5168\u5C4F\u9884\u89C8\u65F6\u4F5C\u4E3A\u6807\u9898\u663E\u793A |
thumb | \u56FE\u7247\u7F29\u7565\u56FE\u6216\u89C6\u9891\u5C01\u9762\u7684\u7F51\u7EDC\u8D44\u6E90\u5730\u5740\uFF0C\u4EC5\u5BF9\u56FE\u7247\u548C\u89C6\u9891\u6709\u6548\uFF0Caccept \u4E3A video \u65F6\uFF0C\u771F\u673A\u4E0D\u4F1A\u8FD4\u56DE\u8BE5\u5C5E\u6027\uFF0C\u5EFA\u8BAE\u4F7F\u7528 media \u548C media-type \u914D\u5408\u5B8C\u6210\u89C6\u9891\u4E0A\u4F20 |
type | \u6587\u4EF6\u7C7B\u578B\uFF0C\u53EF\u9009\u503Cimage video file |
isImage | \u624B\u52A8\u6807\u8BB0\u56FE\u7247\u8D44\u6E90 |
isVideo | \u624B\u52A8\u6807\u8BB0\u89C6\u9891\u8D44\u6E90 |
\u540D\u79F0 | \u8BF4\u660E |
---|---|
- | \u81EA\u5B9A\u4E49\u4E0A\u4F20\u533A\u57DF |
\u4E8B\u4EF6\u540D | \u8BF4\u660E | \u56DE\u8C03\u53C2\u6570 |
---|---|---|
bind:before-read | \u6587\u4EF6\u8BFB\u53D6\u524D\uFF0C\u5728\u56DE\u8C03\u51FD\u6570\u4E2D\u8FD4\u56DE false \u53EF\u7EC8\u6B62\u6587\u4EF6\u8BFB\u53D6\uFF0C\u7ED1\u5B9A\u4E8B\u4EF6\u7684\u540C\u65F6\u9700\u8981\u5C06use-before-read \u5C5E\u6027\u8BBE\u7F6E\u4E3Atrue | event.detail.file : \u5F53\u524D\u8BFB\u53D6\u7684\u6587\u4EF6\uFF0Cevent.detail.callback : \u56DE\u8C03\u51FD\u6570\uFF0C\u8C03\u7528callback(false) \u7EC8\u6B62\u6587\u4EF6\u8BFB\u53D6 |
bind:after-read | \u6587\u4EF6\u8BFB\u53D6\u5B8C\u6210\u540E | event.detail.file : \u5F53\u524D\u8BFB\u53D6\u7684\u6587\u4EF6 |
bind:oversize | \u6587\u4EF6\u8D85\u51FA\u5927\u5C0F\u9650\u5236 | - |
bind:click-preview | \u70B9\u51FB\u9884\u89C8\u56FE\u7247 | event.detail.index : \u70B9\u51FB\u56FE\u7247\u7684\u5E8F\u53F7\u503C |
bind:delete | \u5220\u9664\u56FE\u7247 | event.detail.index : \u5220\u9664\u56FE\u7247\u7684\u5E8F\u53F7\u503C |