diff --git a/dist/cascader/index.js b/dist/cascader/index.js index 03680f59..0bc2b269 100644 --- a/dist/cascader/index.js +++ b/dist/cascader/index.js @@ -148,6 +148,7 @@ VantComponent({ selected: null, }, ], + activeTab: 0, }); }, onClose() { diff --git a/dist/definitions/index.d.ts b/dist/definitions/index.d.ts index d0554f62..c90321fb 100644 --- a/dist/definitions/index.d.ts +++ b/dist/definitions/index.d.ts @@ -4,6 +4,7 @@ interface VantComponentInstance { children: WechatMiniprogram.Component.TrivialInstance[]; index: number; $emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void; + setView: (value: Record, callback?: () => void) => void; } export type VantComponentOptions = { data?: Data; diff --git a/dist/field/index.js b/dist/field/index.js index 5b07135e..76522c8d 100644 --- a/dist/field/index.js +++ b/dist/field/index.js @@ -31,6 +31,18 @@ VantComponent({ innerValue: '', showClear: false, }, + watch: { + value(value) { + if (value !== this.value) { + this.setData({ innerValue: value }); + this.value = value; + this.setShowClear(); + } + }, + clearTrigger() { + this.setShowClear(); + }, + }, created() { this.value = this.data.value; this.setData({ innerValue: this.value }); @@ -119,7 +131,7 @@ VantComponent({ const trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused); showClear = hasValue && trigger; } - this.setData({ showClear }); + this.setView({ showClear }); }, noop() { }, }, diff --git a/dist/field/props.js b/dist/field/props.js index ae405b31..ba3e0a71 100644 --- a/dist/field/props.js +++ b/dist/field/props.js @@ -1,13 +1,5 @@ export const commonProps = { - value: { - type: String, - observer(value) { - if (value !== this.value) { - this.setData({ innerValue: value }); - this.value = value; - } - }, - }, + value: String, placeholder: String, placeholderStyle: String, placeholderClass: String, diff --git a/dist/mixins/basic.js b/dist/mixins/basic.js index 617cc070..62da6f97 100644 --- a/dist/mixins/basic.js +++ b/dist/mixins/basic.js @@ -7,5 +7,20 @@ export const basic = Behavior({ this.setData(data); return new Promise((resolve) => wx.nextTick(resolve)); }, + // high performance setData + setView(data, callback) { + const target = {}; + let hasChange = false; + Object.keys(data).forEach((key) => { + if (data[key] !== this.data[key]) { + target[key] = data[key]; + hasChange = true; + } + }); + if (hasChange) { + return this.setData(target, callback); + } + return callback && callback(); + }, }, }); diff --git a/dist/uploader/index.js b/dist/uploader/index.js index 5379c1ba..93a4962b 100644 --- a/dist/uploader/index.js +++ b/dist/uploader/index.js @@ -1,7 +1,7 @@ import { VantComponent } from '../common/component'; -import { isImageFile, chooseFile, isVideoFile } from './utils'; -import { imageProps, videoProps, mediaProps, messageFileProps } from './shared'; import { isBoolean, isPromise } from '../common/validator'; +import { imageProps, mediaProps, messageFileProps, videoProps } from './shared'; +import { chooseFile, isImageFile, isVideoFile } from './utils'; VantComponent({ props: Object.assign(Object.assign(Object.assign(Object.assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: { type: null, diff --git a/dist/uploader/index.wxml b/dist/uploader/index.wxml index 3e61fd9f..2276fbf4 100644 --- a/dist/uploader/index.wxml +++ b/dist/uploader/index.wxml @@ -29,6 +29,7 @@ poster="{{ item.thumb }}" autoplay="{{ item.autoplay }}" object-fit="{{videoFit}}" + referrer-policy="{{videoReferrerPolicy}}" class="van-uploader__preview-image" style="{{ computed.sizeStyle({ previewSize }) }}" data-index="{{ index }}" diff --git a/dist/uploader/shared.d.ts b/dist/uploader/shared.d.ts index e0a0d7e3..77b45415 100644 --- a/dist/uploader/shared.d.ts +++ b/dist/uploader/shared.d.ts @@ -29,6 +29,10 @@ export declare const videoProps: { type: StringConstructor; value: string; }; + referrerPolicy: { + type: StringConstructor; + value: string; + }; }; export declare const mediaProps: { capture: { diff --git a/dist/uploader/shared.js b/dist/uploader/shared.js index c481c23a..312fea4e 100644 --- a/dist/uploader/shared.js +++ b/dist/uploader/shared.js @@ -31,6 +31,10 @@ export const videoProps = { type: String, value: 'back', }, + referrerPolicy: { + type: String, + value: 'no-referrer', + }, }; // props for media export const mediaProps = { diff --git a/example/project.config.json b/example/project.config.json index 3db8cd77..d9384d95 100644 --- a/example/project.config.json +++ b/example/project.config.json @@ -42,7 +42,7 @@ "condition": false }, "compileType": "miniprogram", - "libVersion": "2.6.5", + "libVersion": "2.27.3", "appid": "wx1c01b35002d3ba14", "projectname": "vant-weapp", "condition": { diff --git a/lib/cascader/index.js b/lib/cascader/index.js index 1b45831b..f7c239c4 100644 --- a/lib/cascader/index.js +++ b/lib/cascader/index.js @@ -161,6 +161,7 @@ var defaultFieldNames = { selected: null, }, ], + activeTab: 0, }); }, onClose: function () { diff --git a/lib/definitions/index.d.ts b/lib/definitions/index.d.ts index d0554f62..c90321fb 100644 --- a/lib/definitions/index.d.ts +++ b/lib/definitions/index.d.ts @@ -4,6 +4,7 @@ interface VantComponentInstance { children: WechatMiniprogram.Component.TrivialInstance[]; index: number; $emit: (name: string, detail?: unknown, options?: WechatMiniprogram.Component.TriggerEventOption) => void; + setView: (value: Record, callback?: () => void) => void; } export type VantComponentOptions = { data?: Data; diff --git a/lib/field/index.js b/lib/field/index.js index 4fff56ae..ee64d5f1 100644 --- a/lib/field/index.js +++ b/lib/field/index.js @@ -44,6 +44,18 @@ var props_1 = require("./props"); innerValue: '', showClear: false, }, + watch: { + value: function (value) { + if (value !== this.value) { + this.setData({ innerValue: value }); + this.value = value; + this.setShowClear(); + } + }, + clearTrigger: function () { + this.setShowClear(); + }, + }, created: function () { this.value = this.data.value; this.setData({ innerValue: this.value }); @@ -133,7 +145,7 @@ var props_1 = require("./props"); var trigger = clearTrigger === 'always' || (clearTrigger === 'focus' && focused); showClear = hasValue && trigger; } - this.setData({ showClear: showClear }); + this.setView({ showClear: showClear }); }, noop: function () { }, }, diff --git a/lib/field/props.js b/lib/field/props.js index 3cb8dca7..5ec647b2 100644 --- a/lib/field/props.js +++ b/lib/field/props.js @@ -2,15 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.textareaProps = exports.inputProps = exports.commonProps = void 0; exports.commonProps = { - value: { - type: String, - observer: function (value) { - if (value !== this.value) { - this.setData({ innerValue: value }); - this.value = value; - } - }, - }, + value: String, placeholder: String, placeholderStyle: String, placeholderClass: String, diff --git a/lib/mixins/basic.js b/lib/mixins/basic.js index 4373ad44..405161a2 100644 --- a/lib/mixins/basic.js +++ b/lib/mixins/basic.js @@ -10,5 +10,21 @@ exports.basic = Behavior({ this.setData(data); return new Promise(function (resolve) { return wx.nextTick(resolve); }); }, + // high performance setData + setView: function (data, callback) { + var _this = this; + var target = {}; + var hasChange = false; + Object.keys(data).forEach(function (key) { + if (data[key] !== _this.data[key]) { + target[key] = data[key]; + hasChange = true; + } + }); + if (hasChange) { + return this.setData(target, callback); + } + return callback && callback(); + }, }, }); diff --git a/lib/uploader/index.js b/lib/uploader/index.js index 5492d408..7842d9b6 100644 --- a/lib/uploader/index.js +++ b/lib/uploader/index.js @@ -12,9 +12,9 @@ var __assign = (this && this.__assign) || function () { }; Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = require("../common/component"); -var utils_1 = require("./utils"); -var shared_1 = require("./shared"); var validator_1 = require("../common/validator"); +var shared_1 = require("./shared"); +var utils_1 = require("./utils"); (0, component_1.VantComponent)({ props: __assign(__assign(__assign(__assign({ disabled: Boolean, multiple: Boolean, uploadText: String, useBeforeRead: Boolean, afterRead: null, beforeRead: null, previewSize: { type: null, diff --git a/lib/uploader/index.wxml b/lib/uploader/index.wxml index 3e61fd9f..2276fbf4 100644 --- a/lib/uploader/index.wxml +++ b/lib/uploader/index.wxml @@ -29,6 +29,7 @@ poster="{{ item.thumb }}" autoplay="{{ item.autoplay }}" object-fit="{{videoFit}}" + referrer-policy="{{videoReferrerPolicy}}" class="van-uploader__preview-image" style="{{ computed.sizeStyle({ previewSize }) }}" data-index="{{ index }}" diff --git a/lib/uploader/shared.d.ts b/lib/uploader/shared.d.ts index e0a0d7e3..77b45415 100644 --- a/lib/uploader/shared.d.ts +++ b/lib/uploader/shared.d.ts @@ -29,6 +29,10 @@ export declare const videoProps: { type: StringConstructor; value: string; }; + referrerPolicy: { + type: StringConstructor; + value: string; + }; }; export declare const mediaProps: { capture: { diff --git a/lib/uploader/shared.js b/lib/uploader/shared.js index b88fea74..67f32637 100644 --- a/lib/uploader/shared.js +++ b/lib/uploader/shared.js @@ -34,6 +34,10 @@ exports.videoProps = { type: String, value: 'back', }, + referrerPolicy: { + type: String, + value: 'no-referrer', + }, }; // props for media exports.mediaProps = {