$Modal support render, fixed #1041
This commit is contained in:
parent
dce5a3ea6b
commit
3ef24d5fe5
4 changed files with 56 additions and 22 deletions
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
{{ val }}
|
||||||
<Button @click="confirm">标准</Button>
|
<Button @click="confirm">标准</Button>
|
||||||
<Button @click="custom">自定义按钮文字</Button>
|
<Button @click="custom">自定义按钮文字</Button>
|
||||||
<Button @click="async">异步关闭</Button>
|
<Button @click="async">异步关闭</Button>
|
||||||
|
@ -19,7 +20,8 @@
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
modal1: false
|
modal1: false,
|
||||||
|
val: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -33,6 +35,19 @@
|
||||||
this.$Modal.confirm({
|
this.$Modal.confirm({
|
||||||
title: '确认对话框标题',
|
title: '确认对话框标题',
|
||||||
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
||||||
|
render: (h) => {
|
||||||
|
return h('Input', {
|
||||||
|
props: {
|
||||||
|
value: this.val,
|
||||||
|
autofocus: true
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
input: (val) => {
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, '一个按钮')
|
||||||
|
},
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.$Message.info('点击了确定');
|
this.$Message.info('点击了确定');
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,6 +48,35 @@ Modal.newInstance = properties => {
|
||||||
}
|
}
|
||||||
}, this.localeOkText));
|
}, this.localeOkText));
|
||||||
|
|
||||||
|
// render content
|
||||||
|
let body_render;
|
||||||
|
if (this.render) {
|
||||||
|
body_render = h('div', {
|
||||||
|
attrs: {
|
||||||
|
class: `${prefixCls}-body ${prefixCls}-body-render`
|
||||||
|
}
|
||||||
|
}, [this.render(h)]);
|
||||||
|
} else {
|
||||||
|
body_render = h('div', {
|
||||||
|
attrs: {
|
||||||
|
class: `${prefixCls}-body`
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
h('div', {
|
||||||
|
class: this.iconTypeCls
|
||||||
|
}, [
|
||||||
|
h('i', {
|
||||||
|
class: this.iconNameCls
|
||||||
|
})
|
||||||
|
]),
|
||||||
|
h('div', {
|
||||||
|
domProps: {
|
||||||
|
innerHTML: this.body
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return h(Modal, {
|
return h(Modal, {
|
||||||
props: Object.assign({}, _props, {
|
props: Object.assign({}, _props, {
|
||||||
width: this.width,
|
width: this.width,
|
||||||
|
@ -81,24 +110,7 @@ Modal.newInstance = properties => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
h('div', {
|
body_render,
|
||||||
attrs: {
|
|
||||||
class: `${prefixCls}-body`
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
h('div', {
|
|
||||||
class: this.iconTypeCls
|
|
||||||
}, [
|
|
||||||
h('i', {
|
|
||||||
class: this.iconNameCls
|
|
||||||
})
|
|
||||||
]),
|
|
||||||
h('div', {
|
|
||||||
domProps: {
|
|
||||||
innerHTML: this.body
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]),
|
|
||||||
h('div', {
|
h('div', {
|
||||||
attrs: {
|
attrs: {
|
||||||
class: `${prefixCls}-footer`
|
class: `${prefixCls}-footer`
|
||||||
|
|
|
@ -2,18 +2,20 @@ import Modal from './confirm';
|
||||||
|
|
||||||
let modalInstance;
|
let modalInstance;
|
||||||
|
|
||||||
function getModalInstance () {
|
function getModalInstance (render = undefined) {
|
||||||
modalInstance = modalInstance || Modal.newInstance({
|
modalInstance = modalInstance || Modal.newInstance({
|
||||||
closable: false,
|
closable: false,
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
footerHide: true
|
footerHide: true,
|
||||||
|
render: render
|
||||||
});
|
});
|
||||||
|
|
||||||
return modalInstance;
|
return modalInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirm (options) {
|
function confirm (options) {
|
||||||
let instance = getModalInstance();
|
const render = ('render' in options) ? options.render : undefined;
|
||||||
|
let instance = getModalInstance(render);
|
||||||
|
|
||||||
options.onRemove = function () {
|
options.onRemove = function () {
|
||||||
modalInstance = null;
|
modalInstance = null;
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
color: @text-color;
|
color: @text-color;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
&-render{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&-icon {
|
&-icon {
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
Loading…
Add table
Reference in a new issue