diff --git a/dist/checkbox/index.js b/dist/checkbox/index.js index 4491e3be..4810123a 100644 --- a/dist/checkbox/index.js +++ b/dist/checkbox/index.js @@ -1,5 +1,4 @@ import { VantComponent } from '../common/component'; -import { addUnit } from '../common/utils'; function emit(target, value) { target.$emit('input', value); target.$emit('change', value); @@ -30,12 +29,9 @@ VantComponent({ }, iconSize: { type: null, - observer: 'setSizeWithUnit' + value: 20 } }, - data: { - sizeWithUnit: '20px' - }, methods: { emitChange(value) { if (this.parent) { @@ -77,11 +73,6 @@ VantComponent({ emit(parent, parentValue); } } - }, - setSizeWithUnit(size) { - this.set({ - sizeWithUnit: addUnit(size) - }); - }, + } } }); diff --git a/dist/checkbox/index.wxml b/dist/checkbox/index.wxml index 65124a16..19a89260 100644 --- a/dist/checkbox/index.wxml +++ b/dist/checkbox/index.wxml @@ -8,7 +8,7 @@ name="success" size="0.8em" class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}" - style="font-size: {{ sizeWithUnit }};{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" + style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" custom-class="icon-class" custom-style="line-height: 1.25em;" /> diff --git a/dist/checkbox/index.wxss b/dist/checkbox/index.wxss index d217597e..afaf37be 100644 --- a/dist/checkbox/index.wxss +++ b/dist/checkbox/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file +@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file diff --git a/dist/dialog/index.js b/dist/dialog/index.js index 85d6c3c1..66ea2e69 100644 --- a/dist/dialog/index.js +++ b/dist/dialog/index.js @@ -1,7 +1,6 @@ import { VantComponent } from '../common/component'; import { button } from '../mixins/button'; import { openType } from '../mixins/open-type'; -import { addUnit } from '../common/utils'; import { GRAY, BLUE } from '../common/color'; VantComponent({ mixins: [button, openType], @@ -19,10 +18,7 @@ VantComponent({ showCancelButton: Boolean, closeOnClickOverlay: Boolean, confirmButtonOpenType: String, - width: { - type: null, - observer: 'setWidthWithUnit' - }, + width: null, zIndex: { type: Number, value: 2000 @@ -109,11 +105,6 @@ VantComponent({ if (callback) { callback(this); } - }, - setWidthWithUnit(val) { - this.setData({ - widthWithUnit: addUnit(val) - }); } } }); diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml index 854e8a14..5442c799 100644 --- a/dist/dialog/index.wxml +++ b/dist/dialog/index.wxml @@ -1,10 +1,12 @@ + + 1) { + rightBorderLess = index !== length - 1; + } this.setData({ isFirst: index === 0, - isLast: index === children.length - 1 + rightBorderLess, + isLast: index === length - 1 }); } } diff --git a/dist/goods-action-button/index.wxml b/dist/goods-action-button/index.wxml index d6d2daab..392b96d9 100644 --- a/dist/goods-action-button/index.wxml +++ b/dist/goods-action-button/index.wxml @@ -5,10 +5,11 @@ lang="{{ lang }}" type="{{ type }}" color="{{ color }}" + plain="{{ plain }}" loading="{{ loading }}" disabled="{{ disabled }}" open-type="{{ openType }}" - custom-class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast }]) }}" + custom-class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain : plain, ordinary: !plain }])}} {{ rightBorderLess ?'van-goods-action-button--no-right-border': ''}}" business-id="{{ businessId }}" session-from="{{ sessionFrom }}" app-parameter="{{ appParameter }}" diff --git a/dist/goods-action-button/index.wxss b/dist/goods-action-button/index.wxss index 5b603f1f..c37f9b07 100644 --- a/dist/goods-action-button/index.wxss +++ b/dist/goods-action-button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}.van-goods-action-button--ordinary{border:none!important}.van-goods-action-button--plain{background:#fff;background:var(--goods-action-button-plain-color,#fff)}.van-goods-action-button--no-right-border{border-right-width:0!important}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/dist/icon/index.js b/dist/icon/index.js index 8d83ff19..2cfe253b 100644 --- a/dist/icon/index.js +++ b/dist/icon/index.js @@ -1,13 +1,9 @@ import { VantComponent } from '../common/component'; -import { addUnit } from '../common/utils'; VantComponent({ props: { dot: Boolean, info: null, - size: { - type: null, - observer: 'setSizeWithUnit' - }, + size: null, color: String, customStyle: String, classPrefix: { @@ -23,17 +19,9 @@ VantComponent({ } } }, - data: { - sizeWithUnit: null, - }, methods: { onClick() { this.$emit('click'); - }, - setSizeWithUnit(size) { - this.setData({ - sizeWithUnit: addUnit(size) - }); } } }); diff --git a/dist/icon/index.wxml b/dist/icon/index.wxml index c568b58e..fe4065a4 100644 --- a/dist/icon/index.wxml +++ b/dist/icon/index.wxml @@ -1,6 +1,8 @@ + + + - + diff --git a/dist/mixins/observer/behavior.js b/dist/mixins/observer/behavior.js index 948f446b..4f4d7f3b 100644 --- a/dist/mixins/observer/behavior.js +++ b/dist/mixins/observer/behavior.js @@ -1,14 +1,8 @@ export const behavior = Behavior({ methods: { set(data, callback) { - return new Promise(resolve => { - this.setData(data, () => { - if (callback && typeof callback === 'function') { - callback.call(this); - } - resolve(); - }); - }); + this.setData(data, callback); + return new Promise(resolve => wx.nextTick(resolve)); } } }); diff --git a/dist/notice-bar/index.js b/dist/notice-bar/index.js index faf35677..299a6892 100644 --- a/dist/notice-bar/index.js +++ b/dist/notice-bar/index.js @@ -51,6 +51,9 @@ VantComponent({ watch: { text() { this.setData({}, this.init); + }, + speed() { + this.setData({}, this.init); } }, created() { diff --git a/dist/notify/index.js b/dist/notify/index.js index db9ba762..4ba095cd 100644 --- a/dist/notify/index.js +++ b/dist/notify/index.js @@ -33,9 +33,8 @@ VantComponent({ show() { const { duration, onOpened } = this.data; clearTimeout(this.timer); - this.setData({ - show: true - }, onOpened); + this.setData({ show: true }); + wx.nextTick(onOpened); if (duration > 0 && duration !== Infinity) { this.timer = setTimeout(() => { this.hide(); @@ -45,9 +44,8 @@ VantComponent({ hide() { const { onClose } = this.data; clearTimeout(this.timer); - this.setData({ - show: false - }, onClose); + this.setData({ show: false }); + wx.nextTick(onClose); }, onTap(event) { const { onClick } = this.data; diff --git a/dist/notify/index.wxml b/dist/notify/index.wxml index 552b8e36..5ef0d8c4 100644 --- a/dist/notify/index.wxml +++ b/dist/notify/index.wxml @@ -9,7 +9,10 @@ class="van-notify van-notify--{{ type }}" style="background:{{ background }};color:{{ color }};" > - + {{ message }} diff --git a/dist/notify/notify.js b/dist/notify/notify.js index 140690b6..bbb7222c 100644 --- a/dist/notify/notify.js +++ b/dist/notify/notify.js @@ -7,6 +7,7 @@ const defaultOptions = { duration: 3000, zIndex: 110, color: WHITE, + safeAreaInsetTop: false, onClick: () => { }, onOpened: () => { }, onClose: () => { } @@ -25,7 +26,7 @@ export default function Notify(options) { delete options.context; delete options.selector; if (notify) { - notify.set(options); + notify.setData(options); notify.show(); return notify; } diff --git a/dist/progress/index.js b/dist/progress/index.js index 6ca67bd5..c1615fc8 100644 --- a/dist/progress/index.js +++ b/dist/progress/index.js @@ -1,6 +1,5 @@ import { VantComponent } from '../common/component'; import { BLUE } from '../common/color'; -import { addUnit } from '../common/utils'; VantComponent({ props: { inactive: Boolean, @@ -22,17 +21,7 @@ VantComponent({ }, strokeWidth: { type: null, - observer: 'setStrokeWidthUnit' - } - }, - data: { - strokeWidthUnit: '4px' - }, - methods: { - setStrokeWidthUnit(val) { - this.setData({ - strokeWidthUnit: addUnit(val) - }); + value: 4 } } }); diff --git a/dist/progress/index.wxml b/dist/progress/index.wxml index 5d27517d..e5981f09 100644 --- a/dist/progress/index.wxml +++ b/dist/progress/index.wxml @@ -1,8 +1,9 @@ + - + {{ item.text }} @@ -15,14 +16,14 @@ @@ -30,7 +31,7 @@ @@ -44,7 +45,7 @@ function get(index, active) { return 'process'; } - return ''; + return 'inactive'; } module.exports = get; diff --git a/dist/tag/index.json b/dist/tag/index.json index 32640e0d..0a336c08 100644 --- a/dist/tag/index.json +++ b/dist/tag/index.json @@ -1,3 +1,6 @@ { - "component": true -} \ No newline at end of file + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/dist/tree-select/index.js b/dist/tree-select/index.js index bf824107..2630e35e 100644 --- a/dist/tree-select/index.js +++ b/dist/tree-select/index.js @@ -1,5 +1,4 @@ import { VantComponent } from '../common/component'; -import { addUnit } from '../common/utils'; VantComponent({ classes: [ 'main-item-class', @@ -22,8 +21,7 @@ VantComponent({ }, height: { type: [Number, String], - value: 300, - observer: 'updateHeight' + value: 300 }, max: { type: Number, @@ -33,9 +31,6 @@ VantComponent({ data: { subItems: [] }, - created() { - this.updateHeight(); - }, methods: { // 当一个子项被选择时 onSelectItem(event) { @@ -64,11 +59,6 @@ VantComponent({ const { items, mainActiveIndex } = this.data; const { children = [] } = items[mainActiveIndex] || {}; return this.set({ subItems: children }); - }, - updateHeight() { - this.setData({ - innerHeight: addUnit(this.data.height) - }); } } }); diff --git a/dist/tree-select/index.wxml b/dist/tree-select/index.wxml index d6f95a8a..547a94af 100644 --- a/dist/tree-select/index.wxml +++ b/dist/tree-select/index.wxml @@ -3,7 +3,7 @@ diff --git a/dist/uploader/index.js b/dist/uploader/index.js index 9cc5def1..cc0fff81 100644 --- a/dist/uploader/index.js +++ b/dist/uploader/index.js @@ -1,17 +1,14 @@ import { VantComponent } from '../common/component'; import { isImageFile } from './utils'; -import { addUnit } from '../common/utils'; VantComponent({ props: { disabled: Boolean, multiple: Boolean, uploadText: String, - useSlot: Boolean, useBeforeRead: Boolean, previewSize: { type: null, - value: 90, - observer: 'setComputedPreviewSize' + value: 90 }, name: { type: [Number, String], @@ -21,6 +18,14 @@ VantComponent({ type: String, value: 'image' }, + sizeType: { + type: Array, + value: ['original', 'compressed'] + }, + capture: { + type: Array, + value: ['album', 'camera'] + }, fileList: { type: Array, value: [], @@ -62,15 +67,10 @@ VantComponent({ const lists = fileList.map(item => (Object.assign(Object.assign({}, item), { isImage: typeof item.isImage === 'undefined' ? isImageFile(item) : item.isImage }))); this.setData({ lists, isInCount: lists.length < maxCount }); }, - setComputedPreviewSize(val) { - this.setData({ - computedPreviewSize: addUnit(val) - }); - }, startUpload() { if (this.data.disabled) return; - const { name = '', capture = ['album', 'camera'], maxCount = 100, multiple = false, maxSize, accept, lists, useBeforeRead = false // 是否定义了 beforeRead + const { name = '', capture, maxCount, multiple, maxSize, accept, sizeType, lists, useBeforeRead = false // 是否定义了 beforeRead } = this.data; let chooseFile = null; const newMaxCount = maxCount - lists.length; @@ -80,6 +80,7 @@ VantComponent({ wx.chooseImage({ count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, sourceType: capture, + sizeType, success: resolve, fail: reject }); @@ -95,7 +96,8 @@ VantComponent({ }); }); } - chooseFile.then((res) => { + chooseFile + .then((res) => { const file = multiple ? res.tempFiles : res.tempFiles[0]; // 检查文件大小 if (file instanceof Array) { @@ -125,6 +127,9 @@ VantComponent({ else { this.$emit('after-read', { file, name }); } + }) + .catch(error => { + this.$emit('error', error); }); }, deleteItem(event) { diff --git a/dist/uploader/index.wxml b/dist/uploader/index.wxml index 02546aa9..81223fd1 100644 --- a/dist/uploader/index.wxml +++ b/dist/uploader/index.wxml @@ -15,14 +15,14 @@ src="{{ item.url || item.path }}" alt="{{ item.name || ('图片' + index) }}" class="van-uploader__preview-image" - style="width: {{ computedPreviewSize }}; height: {{ computedPreviewSize }};" + style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};" data-url="{{ item.url || item.path }}" bind:tap="doPreviewImage" /> {{ item.name || item.url || item.path }} @@ -38,15 +38,14 @@ - + diff --git a/dist/uploader/index.wxss b/dist/uploader/index.wxss index ed705822..a1508ab5 100644 --- a/dist/uploader/index.wxss +++ b/dist/uploader/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #ebedf0;border-radius:4px}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px;border-radius:4px}.van-uploader__preview-delete{position:absolute;top:-8px;right:-8px;color:#969799;font-size:18px;background-color:#fff;border-radius:100%}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa;border-radius:4px}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#646566;font-size:12px;text-align:center} \ No newline at end of file +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__slot:empty{display:none}.van-uploader__slot:not(:empty)+.van-uploader__upload{display:none!important}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #ebedf0;border-radius:4px}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px;border-radius:4px}.van-uploader__preview-delete{position:absolute;top:-8px;right:-8px;color:#969799;font-size:18px;background-color:#fff;border-radius:100%}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa;border-radius:4px}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#646566;font-size:12px;text-align:center} \ No newline at end of file diff --git a/dist/wxs/add-unit.wxs b/dist/wxs/add-unit.wxs new file mode 100644 index 00000000..27a22d82 --- /dev/null +++ b/dist/wxs/add-unit.wxs @@ -0,0 +1,14 @@ +/* eslint-disable */ +var REGEXP = getRegExp('^\d+(\.\d+)?$'); + +function addUnit(value) { + if (value == null) { + return undefined; + } + + return REGEXP.test('' + value) ? value + 'px' : value; +} + +module.exports = { + addUnit: addUnit +}; diff --git a/dist/wxs/utils.wxs b/dist/wxs/utils.wxs index a18662df..d5c9d8c2 100644 --- a/dist/wxs/utils.wxs +++ b/dist/wxs/utils.wxs @@ -1,7 +1,10 @@ +/* eslint-disable */ var bem = require('./bem.wxs').bem; var memoize = require('./memoize.wxs').memoize; +var addUnit = require('./add-unit.wxs').addUnit; module.exports = { bem: memoize(bem), - memoize: memoize + memoize: memoize, + addUnit: addUnit }; diff --git a/lib/checkbox/index.js b/lib/checkbox/index.js index 535eb41d..86c60ddd 100644 --- a/lib/checkbox/index.js +++ b/lib/checkbox/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var utils_1 = require("../common/utils"); function emit(target, value) { target.$emit('input', value); target.$emit('change', value); @@ -32,12 +31,9 @@ component_1.VantComponent({ }, iconSize: { type: null, - observer: 'setSizeWithUnit' + value: 20 } }, - data: { - sizeWithUnit: '20px' - }, methods: { emitChange: function (value) { if (this.parent) { @@ -79,11 +75,6 @@ component_1.VantComponent({ emit(parent, parentValue); } } - }, - setSizeWithUnit: function (size) { - this.set({ - sizeWithUnit: utils_1.addUnit(size) - }); - }, + } } }); diff --git a/lib/checkbox/index.wxml b/lib/checkbox/index.wxml index 65124a16..19a89260 100644 --- a/lib/checkbox/index.wxml +++ b/lib/checkbox/index.wxml @@ -8,7 +8,7 @@ name="success" size="0.8em" class="{{ utils.bem('checkbox__icon', [shape, { disabled, checked: value }]) }}" - style="font-size: {{ sizeWithUnit }};{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" + style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && value && !disabled ? 'border-color:' + checkedColor + '; background-color:' + checkedColor : '' }}" custom-class="icon-class" custom-style="line-height: 1.25em;" /> diff --git a/lib/checkbox/index.wxss b/lib/checkbox/index.wxss index d217597e..afaf37be 100644 --- a/lib/checkbox/index.wxss +++ b/lib/checkbox/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file +@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} \ No newline at end of file diff --git a/lib/dialog/index.js b/lib/dialog/index.js index 6748bc7a..ba3a7b67 100644 --- a/lib/dialog/index.js +++ b/lib/dialog/index.js @@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); var button_1 = require("../mixins/button"); var open_type_1 = require("../mixins/open-type"); -var utils_1 = require("../common/utils"); var color_1 = require("../common/color"); component_1.VantComponent({ mixins: [button_1.button, open_type_1.openType], @@ -21,10 +20,7 @@ component_1.VantComponent({ showCancelButton: Boolean, closeOnClickOverlay: Boolean, confirmButtonOpenType: String, - width: { - type: null, - observer: 'setWidthWithUnit' - }, + width: null, zIndex: { type: Number, value: 2000 @@ -112,11 +108,6 @@ component_1.VantComponent({ if (callback) { callback(this); } - }, - setWidthWithUnit: function (val) { - this.setData({ - widthWithUnit: utils_1.addUnit(val) - }); } } }); diff --git a/lib/dialog/index.wxml b/lib/dialog/index.wxml index 854e8a14..5442c799 100644 --- a/lib/dialog/index.wxml +++ b/lib/dialog/index.wxml @@ -1,10 +1,12 @@ + + 1) { + rightBorderLess = index !== length - 1; + } this.setData({ isFirst: index === 0, - isLast: index === children.length - 1 + rightBorderLess: rightBorderLess, + isLast: index === length - 1 }); } } diff --git a/lib/goods-action-button/index.wxml b/lib/goods-action-button/index.wxml index d6d2daab..392b96d9 100644 --- a/lib/goods-action-button/index.wxml +++ b/lib/goods-action-button/index.wxml @@ -5,10 +5,11 @@ lang="{{ lang }}" type="{{ type }}" color="{{ color }}" + plain="{{ plain }}" loading="{{ loading }}" disabled="{{ disabled }}" open-type="{{ openType }}" - custom-class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast }]) }}" + custom-class="{{ utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain : plain, ordinary: !plain }])}} {{ rightBorderLess ?'van-goods-action-button--no-right-border': ''}}" business-id="{{ businessId }}" session-from="{{ sessionFrom }}" app-parameter="{{ appParameter }}" diff --git a/lib/goods-action-button/index.wxss b/lib/goods-action-button/index.wxss index 5b603f1f..c37f9b07 100644 --- a/lib/goods-action-button/index.wxss +++ b/lib/goods-action-button/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{border:none!important;height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{height:40px!important;height:var(--goods-action-button-height,40px)!important;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important;line-height:40px!important;line-height:var(--goods-action-button-height,40px)!important}.van-goods-action-button--first{display:block!important;margin-left:5px;border-top-left-radius:20px!important;border-top-left-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-left-radius:20px!important;border-bottom-left-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--last{display:block!important;margin-right:5px;border-top-right-radius:20px!important;border-top-right-radius:var(--goods-action-button-border-radius,20px)!important;border-bottom-right-radius:20px!important;border-bottom-right-radius:var(--goods-action-button-border-radius,20px)!important}.van-goods-action-button--warning{background:linear-gradient(90deg,#ffd01e,#ff8917);background:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917))}.van-goods-action-button--danger{background:linear-gradient(90deg,#ff6034,#ee0a24);background:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24))}.van-goods-action-button--ordinary{border:none!important}.van-goods-action-button--plain{background:#fff;background:var(--goods-action-button-plain-color,#fff)}.van-goods-action-button--no-right-border{border-right-width:0!important}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/lib/icon/index.js b/lib/icon/index.js index 80a61adb..0363a7fb 100644 --- a/lib/icon/index.js +++ b/lib/icon/index.js @@ -1,15 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var utils_1 = require("../common/utils"); component_1.VantComponent({ props: { dot: Boolean, info: null, - size: { - type: null, - observer: 'setSizeWithUnit' - }, + size: null, color: String, customStyle: String, classPrefix: { @@ -25,17 +21,9 @@ component_1.VantComponent({ } } }, - data: { - sizeWithUnit: null, - }, methods: { onClick: function () { this.$emit('click'); - }, - setSizeWithUnit: function (size) { - this.setData({ - sizeWithUnit: utils_1.addUnit(size) - }); } } }); diff --git a/lib/icon/index.wxml b/lib/icon/index.wxml index c568b58e..fe4065a4 100644 --- a/lib/icon/index.wxml +++ b/lib/icon/index.wxml @@ -1,6 +1,8 @@ + + + - + diff --git a/lib/mixins/observer/behavior.js b/lib/mixins/observer/behavior.js index 4d6e9cbf..3454c0c0 100644 --- a/lib/mixins/observer/behavior.js +++ b/lib/mixins/observer/behavior.js @@ -3,15 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.behavior = Behavior({ methods: { set: function (data, callback) { - var _this = this; - return new Promise(function (resolve) { - _this.setData(data, function () { - if (callback && typeof callback === 'function') { - callback.call(_this); - } - resolve(); - }); - }); + this.setData(data, callback); + return new Promise(function (resolve) { return wx.nextTick(resolve); }); } } }); diff --git a/lib/notice-bar/index.js b/lib/notice-bar/index.js index 25db17c1..19c3e6ed 100644 --- a/lib/notice-bar/index.js +++ b/lib/notice-bar/index.js @@ -53,6 +53,9 @@ component_1.VantComponent({ watch: { text: function () { this.setData({}, this.init); + }, + speed: function () { + this.setData({}, this.init); } }, created: function () { diff --git a/lib/notify/index.js b/lib/notify/index.js index bcc77ac9..2d4a7d0f 100644 --- a/lib/notify/index.js +++ b/lib/notify/index.js @@ -36,9 +36,8 @@ component_1.VantComponent({ var _this = this; var _a = this.data, duration = _a.duration, onOpened = _a.onOpened; clearTimeout(this.timer); - this.setData({ - show: true - }, onOpened); + this.setData({ show: true }); + wx.nextTick(onOpened); if (duration > 0 && duration !== Infinity) { this.timer = setTimeout(function () { _this.hide(); @@ -48,9 +47,8 @@ component_1.VantComponent({ hide: function () { var onClose = this.data.onClose; clearTimeout(this.timer); - this.setData({ - show: false - }, onClose); + this.setData({ show: false }); + wx.nextTick(onClose); }, onTap: function (event) { var onClick = this.data.onClick; diff --git a/lib/notify/index.wxml b/lib/notify/index.wxml index 552b8e36..5ef0d8c4 100644 --- a/lib/notify/index.wxml +++ b/lib/notify/index.wxml @@ -9,7 +9,10 @@ class="van-notify van-notify--{{ type }}" style="background:{{ background }};color:{{ color }};" > - + {{ message }} diff --git a/lib/notify/notify.js b/lib/notify/notify.js index 285ee85e..171aa3be 100644 --- a/lib/notify/notify.js +++ b/lib/notify/notify.js @@ -9,6 +9,7 @@ var defaultOptions = { duration: 3000, zIndex: 110, color: color_1.WHITE, + safeAreaInsetTop: false, onClick: function () { }, onOpened: function () { }, onClose: function () { } @@ -27,7 +28,7 @@ function Notify(options) { delete options.context; delete options.selector; if (notify) { - notify.set(options); + notify.setData(options); notify.show(); return notify; } diff --git a/lib/progress/index.js b/lib/progress/index.js index de74f92a..96a46d3a 100644 --- a/lib/progress/index.js +++ b/lib/progress/index.js @@ -2,7 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); var color_1 = require("../common/color"); -var utils_1 = require("../common/utils"); component_1.VantComponent({ props: { inactive: Boolean, @@ -24,17 +23,7 @@ component_1.VantComponent({ }, strokeWidth: { type: null, - observer: 'setStrokeWidthUnit' - } - }, - data: { - strokeWidthUnit: '4px' - }, - methods: { - setStrokeWidthUnit: function (val) { - this.setData({ - strokeWidthUnit: utils_1.addUnit(val) - }); + value: 4 } } }); diff --git a/lib/progress/index.wxml b/lib/progress/index.wxml index 5d27517d..e5981f09 100644 --- a/lib/progress/index.wxml +++ b/lib/progress/index.wxml @@ -1,8 +1,9 @@ + - + {{ item.text }} @@ -15,14 +16,14 @@ @@ -30,7 +31,7 @@ @@ -44,7 +45,7 @@ function get(index, active) { return 'process'; } - return ''; + return 'inactive'; } module.exports = get; diff --git a/lib/tag/index.json b/lib/tag/index.json index 32640e0d..0a336c08 100644 --- a/lib/tag/index.json +++ b/lib/tag/index.json @@ -1,3 +1,6 @@ { - "component": true -} \ No newline at end of file + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/lib/tree-select/index.js b/lib/tree-select/index.js index 9efc2370..4b41c2bd 100644 --- a/lib/tree-select/index.js +++ b/lib/tree-select/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var utils_1 = require("../common/utils"); component_1.VantComponent({ classes: [ 'main-item-class', @@ -24,8 +23,7 @@ component_1.VantComponent({ }, height: { type: [Number, String], - value: 300, - observer: 'updateHeight' + value: 300 }, max: { type: Number, @@ -35,9 +33,6 @@ component_1.VantComponent({ data: { subItems: [] }, - created: function () { - this.updateHeight(); - }, methods: { // 当一个子项被选择时 onSelectItem: function (event) { @@ -66,11 +61,6 @@ component_1.VantComponent({ var _a = this.data, items = _a.items, mainActiveIndex = _a.mainActiveIndex; var _b = (items[mainActiveIndex] || {}).children, children = _b === void 0 ? [] : _b; return this.set({ subItems: children }); - }, - updateHeight: function () { - this.setData({ - innerHeight: utils_1.addUnit(this.data.height) - }); } } }); diff --git a/lib/tree-select/index.wxml b/lib/tree-select/index.wxml index d6f95a8a..547a94af 100644 --- a/lib/tree-select/index.wxml +++ b/lib/tree-select/index.wxml @@ -3,7 +3,7 @@ diff --git a/lib/uploader/index.js b/lib/uploader/index.js index f57465c5..dadea813 100644 --- a/lib/uploader/index.js +++ b/lib/uploader/index.js @@ -13,18 +13,15 @@ var __assign = (this && this.__assign) || function () { Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); var utils_1 = require("./utils"); -var utils_2 = require("../common/utils"); component_1.VantComponent({ props: { disabled: Boolean, multiple: Boolean, uploadText: String, - useSlot: Boolean, useBeforeRead: Boolean, previewSize: { type: null, - value: 90, - observer: 'setComputedPreviewSize' + value: 90 }, name: { type: [Number, String], @@ -34,6 +31,14 @@ component_1.VantComponent({ type: String, value: 'image' }, + sizeType: { + type: Array, + value: ['original', 'compressed'] + }, + capture: { + type: Array, + value: ['album', 'camera'] + }, fileList: { type: Array, value: [], @@ -75,17 +80,12 @@ component_1.VantComponent({ var lists = fileList.map(function (item) { return (__assign(__assign({}, item), { isImage: typeof item.isImage === 'undefined' ? utils_1.isImageFile(item) : item.isImage })); }); this.setData({ lists: lists, isInCount: lists.length < maxCount }); }, - setComputedPreviewSize: function (val) { - this.setData({ - computedPreviewSize: utils_2.addUnit(val) - }); - }, startUpload: function () { var _this = this; if (this.data.disabled) return; - var _a = this.data, _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.capture, capture = _c === void 0 ? ['album', 'camera'] : _c, _d = _a.maxCount, maxCount = _d === void 0 ? 100 : _d, _e = _a.multiple, multiple = _e === void 0 ? false : _e, maxSize = _a.maxSize, accept = _a.accept, lists = _a.lists, _f = _a.useBeforeRead // 是否定义了 beforeRead - , useBeforeRead = _f === void 0 ? false : _f // 是否定义了 beforeRead + var _a = this.data, _b = _a.name, name = _b === void 0 ? '' : _b, capture = _a.capture, maxCount = _a.maxCount, multiple = _a.multiple, maxSize = _a.maxSize, accept = _a.accept, sizeType = _a.sizeType, lists = _a.lists, _c = _a.useBeforeRead // 是否定义了 beforeRead + , useBeforeRead = _c === void 0 ? false : _c // 是否定义了 beforeRead ; var chooseFile = null; var newMaxCount = maxCount - lists.length; @@ -95,6 +95,7 @@ component_1.VantComponent({ wx.chooseImage({ count: multiple ? (newMaxCount > 9 ? 9 : newMaxCount) : 1, sourceType: capture, + sizeType: sizeType, success: resolve, fail: reject }); @@ -110,7 +111,8 @@ component_1.VantComponent({ }); }); } - chooseFile.then(function (res) { + chooseFile + .then(function (res) { var file = multiple ? res.tempFiles : res.tempFiles[0]; // 检查文件大小 if (file instanceof Array) { @@ -140,6 +142,9 @@ component_1.VantComponent({ else { _this.$emit('after-read', { file: file, name: name }); } + }) + .catch(function (error) { + _this.$emit('error', error); }); }, deleteItem: function (event) { diff --git a/lib/uploader/index.wxml b/lib/uploader/index.wxml index 02546aa9..81223fd1 100644 --- a/lib/uploader/index.wxml +++ b/lib/uploader/index.wxml @@ -15,14 +15,14 @@ src="{{ item.url || item.path }}" alt="{{ item.name || ('图片' + index) }}" class="van-uploader__preview-image" - style="width: {{ computedPreviewSize }}; height: {{ computedPreviewSize }};" + style="width: {{ utils.addUnit(previewSize) }}; height: {{ utils.addUnit(previewSize) }};" data-url="{{ item.url || item.path }}" bind:tap="doPreviewImage" /> {{ item.name || item.url || item.path }} @@ -38,15 +38,14 @@ - + diff --git a/lib/uploader/index.wxss b/lib/uploader/index.wxss index ed705822..a1508ab5 100644 --- a/lib/uploader/index.wxss +++ b/lib/uploader/index.wxss @@ -1 +1 @@ -@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #ebedf0;border-radius:4px}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px;border-radius:4px}.van-uploader__preview-delete{position:absolute;top:-8px;right:-8px;color:#969799;font-size:18px;background-color:#fff;border-radius:100%}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa;border-radius:4px}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#646566;font-size:12px;text-align:center} \ No newline at end of file +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__slot:empty{display:none}.van-uploader__slot:not(:empty)+.van-uploader__upload{display:none!important}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#fff;border:1px dashed #ebedf0;border-radius:4px}.van-uploader__upload-icon{display:inline-block;width:24px;height:24px;color:#969799;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__preview{position:relative;margin:0 8px 8px 0}.van-uploader__preview-image{display:block;width:80px;height:80px;border-radius:4px}.van-uploader__preview-delete{position:absolute;top:-8px;right:-8px;color:#969799;font-size:18px;background-color:#fff;border-radius:100%}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa;border-radius:4px}.van-uploader__file-icon{display:inline-block;width:20px;height:20px;color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 5px;color:#646566;font-size:12px;text-align:center} \ No newline at end of file diff --git a/lib/wxs/add-unit.wxs b/lib/wxs/add-unit.wxs new file mode 100644 index 00000000..27a22d82 --- /dev/null +++ b/lib/wxs/add-unit.wxs @@ -0,0 +1,14 @@ +/* eslint-disable */ +var REGEXP = getRegExp('^\d+(\.\d+)?$'); + +function addUnit(value) { + if (value == null) { + return undefined; + } + + return REGEXP.test('' + value) ? value + 'px' : value; +} + +module.exports = { + addUnit: addUnit +}; diff --git a/lib/wxs/utils.wxs b/lib/wxs/utils.wxs index a18662df..d5c9d8c2 100644 --- a/lib/wxs/utils.wxs +++ b/lib/wxs/utils.wxs @@ -1,7 +1,10 @@ +/* eslint-disable */ var bem = require('./bem.wxs').bem; var memoize = require('./memoize.wxs').memoize; +var addUnit = require('./add-unit.wxs').addUnit; module.exports = { bem: memoize(bem), - memoize: memoize + memoize: memoize, + addUnit: addUnit };