Skip to content

Commit

Permalink
表单设计器 · 开发教程代码
Browse files Browse the repository at this point in the history
  • Loading branch information
JakHuang committed May 5, 2020
1 parent c1b9122 commit 5f67e15
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/components/generator/config.js
Expand Up @@ -519,5 +519,29 @@ export const layoutComponents = [
type: 'default',
justify: 'start',
align: 'top'
},
{
__config__: {
label: '按钮',
showLabel: true,
changeTag: true,
labelWidth: null,
tag: 'el-button',
tagIcon: 'button',
defaultValue: undefined,
span: 24,
layout: 'colFormItem',
document: 'https://element.eleme.cn/#/zh-CN/component/button'
},
__slot__: {
default: '主要按钮'
},
type: 'primary',
icon: 'el-icon-search',
round: false,
size: 'medium',
plain: false,
circle: false,
disabled: false
}
]
5 changes: 5 additions & 0 deletions src/components/render/slots/el-button.js
@@ -0,0 +1,5 @@
export default {
default(h, conf, key) {
return conf.__slot__[key]
}
}
1 change: 1 addition & 0 deletions src/icons/svg/button.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion src/views/index/RightPanel.vue
Expand Up @@ -127,6 +127,16 @@
</el-button>
</el-input>
</el-form-item>
<el-form-item
v-if="activeData['icon']!==undefined && activeData.__config__.tag === 'el-button'"
label="按钮图标"
>
<el-input v-model="activeData['icon']" placeholder="请输入按钮图标名称">
<el-button slot="append" icon="el-icon-thumb" @click="openIconsDialog('icon')">
选择
</el-button>
</el-input>
</el-form-item>
<el-form-item v-if="activeData.__config__.tag === 'el-cascader'" label="选项分隔符">
<el-input v-model="activeData.separator" placeholder="请输入选项分隔符" />
</el-form-item>
Expand Down Expand Up @@ -247,6 +257,19 @@
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="activeData.type !== undefined && activeData.__config__.tag === 'el-button'"
label="按钮类型"
>
<el-select v-model="activeData.type" :style="{ width: '100%' }">
<el-option label="primary" value="primary" />
<el-option label="success" value="success" />
<el-option label="warning" value="warning" />
<el-option label="danger" value="danger" />
<el-option label="info" value="info" />
<el-option label="text" value="text" />
</el-select>
</el-form-item>
<el-form-item
v-if="activeData.__config__.buttonText !== undefined"
v-show="'picture-card' !== activeData['list-type']"
Expand Down Expand Up @@ -417,7 +440,8 @@
v-if="activeData.size !== undefined &&
(activeData.__config__.optionType === 'button' ||
activeData.__config__.border ||
activeData.__config__.tag === 'el-color-picker')"
activeData.__config__.tag === 'el-color-picker' ||
activeData.__config__.tag === 'el-button')"
label="选项尺寸"
>
<el-radio-group v-model="activeData.size">
Expand Down

2 comments on commit 5f67e15

@flexzj
Copy link

@flexzj flexzj commented on 5f67e15 Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以渲染一段文字描述吗

@fl772333621
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持给按钮添加click事件吗?

Please sign in to comment.