From 54253e194326ee22cb42dd5637f6b4c7661bc65c Mon Sep 17 00:00:00 2001 From: JakHuang <352407406@qq.com> Date: Tue, 5 May 2020 20:14:08 +0800 Subject: [PATCH] =?UTF-8?q?vue=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=20=C2=B7=20=E5=BC=80=E5=8F=91=E6=95=99=E7=A8=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/generator/html.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/components/generator/html.js b/src/components/generator/html.js index 494ef036..cf5dfabe 100644 --- a/src/components/generator/html.js +++ b/src/components/generator/html.js @@ -114,6 +114,21 @@ const layouts = { } const tags = { + 'el-button': el => { + const { + tag, disabled + } = attrBuilder(el) + const type = el.type ? `type="${el.type}"` : '' + const icon = el.icon ? `icon="${el.icon}"` : '' + const round = el.round ? 'round' : '' + const size = el.size ? `size="${el.size}"` : '' + const plain = el.plain ? 'plain' : '' + const circle = el.circle ? 'circle' : '' + let child = buildElButtonChild(el) + + if (child) child = `\n${child}\n` // 换行 + return `<${tag} ${type} ${icon} ${round} ${size} ${plain} ${disabled} ${circle}>${child}` + }, 'el-input': el => { const { tag, disabled, vModel, clearable, placeholder, width @@ -283,6 +298,16 @@ function attrBuilder(el) { } } +// el-buttin 子级 +function buildElButtonChild(scheme) { + const children = [] + const slot = scheme.__slot__ || {} + if (slot.default) { + children.push(slot.default) + } + return children.join('\n') +} + // el-input 子级 function buildElInputChild(scheme) { const children = []