diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 9b1a0b12e2cb2e94d583af6ac51c2eef6bc3215d..c660fa6f56e3acf2da04d128b1997b45d0f17c09 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -393,7 +393,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -434,7 +434,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -442,7 +442,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index edcb3831abbd3ddb6c7eaf89684a90aab97d4594..53170bb47ae4c18d9c5f725b74ad7133a63e05c2 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.224", + "version": "0.0.225", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 6d9cf553a54d7b34815b3c1f9130594325f89177..935896fe8935d8adffdc0d5fcc09ac78b309e8d5 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -528,32 +528,25 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] } { if ( - Array.isArray(type) && + defaultValue === false && + Array.isArray(type) && type.length === 2 && - type.indexOf(String) !== -1 + type.indexOf(String) !== -1 && + type.indexOf(Boolean) !== -1 ) { // [String,Boolean]=>Boolean - if (type.indexOf(Boolean) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use Boolean instead of [String,Boolean] . at ${file}` - ); - } - return Boolean - } else if (type.indexOf(Number) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use String or Number instead of [String,Number]. at ${file}` - ); - } - return String + if (file) { + console.warn( + `props.${key}.type should use Boolean instead of [String,Boolean] at ${file}` + ); } + return Boolean } } return type @@ -592,7 +585,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -600,7 +593,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index 83b86e5d091263e83bc3598cc99ec91845876ca0..7d1bb584dc372a45c88726f602b0b991e074b642 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.820", + "version": "0.0.822", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 4f4f9b1c05f95b88abb8b7805ad7eae5e5a308ae..f565d3b0cebca3e4bfd004233897dc6af4fafd1b 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -573,7 +573,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -614,7 +614,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -622,7 +622,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 3178fd0be92486722b1bd615324eb5897ffc6e69..15186f34963c2d4f53a39627341f84a76fdedcc4 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.319", + "version": "0.0.320", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index ffb45f28fc11e64f5ff3ff759f0b66d310ac04a8..aec304b75e750706d86ae1c05b9847a34b420de1 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -420,7 +420,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -461,7 +461,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -469,7 +469,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index e1a5b1d7fed1d5a84acedac67e7dc18594d835cb..e947b4d81e45f77e4155cd3d4bbd53604065caca 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.943", + "version": "0.0.944", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/wrapper/util.js b/src/core/runtime/wrapper/util.js index 6d3f25c4d13f51676a8d04bd7fccfb1da4521645..02396f9804355133b77f13521ecea648c7bc456e 100644 --- a/src/core/runtime/wrapper/util.js +++ b/src/core/runtime/wrapper/util.js @@ -89,32 +89,25 @@ export function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] } if (__PLATFORM__ === 'mp-baidu') { if ( - Array.isArray(type) && + defaultValue === false && + Array.isArray(type) && type.length === 2 && - type.indexOf(String) !== -1 + type.indexOf(String) !== -1 && + type.indexOf(Boolean) !== -1 ) { // [String,Boolean]=>Boolean - if (type.indexOf(Boolean) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use Boolean instead of [String,Boolean] . at ${file}` - ) - } - return Boolean - } else if (type.indexOf(Number) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use String or Number instead of [String,Number]. at ${file}` - ) - } - return String + if (file) { + console.warn( + `props.${key}.type should use Boolean instead of [String,Boolean] at ${file}` + ) } + return Boolean } } return type @@ -153,7 +146,7 @@ export function getProperties (props, isBehavior = false, file = '') { value = value() } - opts.type = parsePropType(key, opts.type, file) + opts.type = parsePropType(key, opts.type, value, file) properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -161,7 +154,7 @@ export function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) } } else { // content:String - const type = parsePropType(key, opts, file) + const type = parsePropType(key, opts, null, file) properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key)