Skip to content

Commit

Permalink
vue代码生成器 · 开发教程代码
Browse files Browse the repository at this point in the history
  • Loading branch information
JakHuang committed May 5, 2020
1 parent 76ae2e9 commit 54253e1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/generator/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}</${tag}>`
},
'el-input': el => {
const {
tag, disabled, vModel, clearable, placeholder, width
Expand Down Expand Up @@ -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 = []
Expand Down

0 comments on commit 54253e1

Please sign in to comment.