提交 f4759747 编写于 作者: fxy060608's avatar fxy060608

build uni runtime(mp-baidu:[String,Number],default:false=>Boolean)

上级 28abd0a5
......@@ -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)
......
{
"name": "@dcloudio/uni-app-plus",
"version": "0.0.224",
"version": "0.0.225",
"description": "uni-app app-plus",
"main": "dist/index.js",
"scripts": {
......
......@@ -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)
......
{
"name": "@dcloudio/uni-mp-baidu",
"version": "0.0.820",
"version": "0.0.822",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
......
......@@ -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)
......
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "0.0.319",
"version": "0.0.320",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"scripts": {
......
......@@ -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)
......
{
"name": "@dcloudio/uni-mp-weixin",
"version": "0.0.943",
"version": "0.0.944",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册