From f9e766ab4a621c58fed446b83a2d03f071c2d60c Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 7 Aug 2023 18:56:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9D=9E=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=92=8C=E5=BF=AB=E9=80=9F=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constants.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/constants.js b/src/constants.js index fb81dee..31612cc 100644 --- a/src/constants.js +++ b/src/constants.js @@ -78,6 +78,26 @@ function getType(v) { ? { type: Array, default: v } : { type: Object, default: v } + case 'string': + let type = String + let attribute = true + if (v.includes('!')) { + v = v.split('!') + let _t = v.shift() + if (_t === 'str') { + v = v.join('!') + } else if (_t === 'num') { + type = Number + v = +v.shift() || 0 + } else if (_t === 'bool') { + type = Boolean + v = v.shift() + v = v !== 'false' && v !== '' + } + attribute = false + } + return { type, default: v, attribute } + default: return { type: String, default: v + '' } }