Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
fb4a7862
Commit
fb4a7862
authored
May 02, 2017
by
杨奕
Committed by
baiyaaaaa
May 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MessageBox: add 'message' support for VNode (#4550)
parent
1e975856
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
12 deletions
+36
-12
examples/components/demo-block.vue
examples/components/demo-block.vue
+3
-2
examples/docs/en-US/message-box.md
examples/docs/en-US/message-box.md
+10
-2
examples/docs/en-US/notification.md
examples/docs/en-US/notification.md
+2
-2
examples/docs/zh-CN/message-box.md
examples/docs/zh-CN/message-box.md
+11
-3
examples/docs/zh-CN/notification.md
examples/docs/zh-CN/notification.md
+2
-2
packages/message-box/src/main.js
packages/message-box/src/main.js
+5
-0
packages/message-box/src/main.vue
packages/message-box/src/main.vue
+3
-1
No files found.
examples/components/demo-block.vue
View file @
fb4a7862
...
@@ -151,6 +151,7 @@
...
@@ -151,6 +151,7 @@
<
script
type=
"text/babel"
>
<
script
type=
"text/babel"
>
import
compoLang
from
'
../i18n/component.json
'
;
import
compoLang
from
'
../i18n/component.json
'
;
import
{
version
}
from
'
main/index.js
'
;
export
default
{
export
default
{
data
()
{
data
()
{
...
@@ -171,10 +172,10 @@
...
@@ -171,10 +172,10 @@
goJsfiddle
()
{
goJsfiddle
()
{
const
{
script
,
html
,
style
}
=
this
.
jsfiddle
;
const
{
script
,
html
,
style
}
=
this
.
jsfiddle
;
const
resourcesTpl
=
'
<scr
'
+
'
ipt src="//unpkg.com/vue/dist/vue.js"></scr
'
+
'
ipt>
'
+
const
resourcesTpl
=
'
<scr
'
+
'
ipt src="//unpkg.com/vue/dist/vue.js"></scr
'
+
'
ipt>
'
+
'
\n
<scr
'
+
'
ipt src="//unpkg.com/element-ui/lib/index.js"></scr
'
+
'
ipt>
'
;
'
\n
<scr
'
+
`ipt src="//unpkg.com/element-ui@
${
version
}
/lib/index.js"></scr`
+
'
ipt>
'
;
let
jsTpl
=
(
script
||
''
).
replace
(
/export default/
,
'
var Main =
'
).
trim
();
let
jsTpl
=
(
script
||
''
).
replace
(
/export default/
,
'
var Main =
'
).
trim
();
let
htmlTpl
=
`
${
resourcesTpl
}
\n<div id="app">\n
${
html
.
trim
()}
\n</div>`
;
let
htmlTpl
=
`
${
resourcesTpl
}
\n<div id="app">\n
${
html
.
trim
()}
\n</div>`
;
let
cssTpl
=
`@import url("//unpkg.com/element-ui/lib/theme-default/index.css");\n
${(
style
||
''
).
trim
()}
\n`
;
let
cssTpl
=
`@import url("//unpkg.com/element-ui
@
${
version
}
/lib/theme-default/index.css");\n
${(
style
||
''
).
trim
()}
\n`
;
jsTpl
=
jsTpl
jsTpl
=
jsTpl
?
jsTpl
+
'
\n
var Ctor = Vue.extend(Main)
\n
new Ctor().$mount(
\'
#app
\'
)
'
?
jsTpl
+
'
\n
var Ctor = Vue.extend(Main)
\n
new Ctor().$mount(
\'
#app
\'
)
'
:
'
new Vue().$mount(
\'
#app
\'
)
'
;
:
'
new Vue().$mount(
\'
#app
\'
)
'
;
...
...
examples/docs/en-US/message-box.md
View file @
fb4a7862
...
@@ -59,9 +59,13 @@
...
@@ -59,9 +59,13 @@
},
},
open4() {
open4() {
const h = this.$createElement;
this.$msgbox({
this.$msgbox({
title: 'Message',
title: 'Message',
message: 'This is a message',
message: h('p', null, [
h('span', null, 'Message can be '),
h('i', { style: 'color: teal' }, 'VNode')
]),
showCancelButton: true,
showCancelButton: true,
confirmButtonText: 'OK',
confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
cancelButtonText: 'Cancel',
...
@@ -219,9 +223,13 @@ Can be customized to show various content.
...
@@ -219,9 +223,13 @@ Can be customized to show various content.
export
default
{
export
default
{
methods
:
{
methods
:
{
open4
()
{
open4
()
{
const
h
=
this
.
$createElement
;
this
.
$msgbox
({
this
.
$msgbox
({
title
:
'
Message
'
,
title
:
'
Message
'
,
message
:
'
This is a message
'
,
message
:
h
(
'
p
'
,
null
,
[
h
(
'
span
'
,
null
,
'
Message can be
'
),
h
(
'
i
'
,
{
style
:
'
color: teal
'
},
'
VNode
'
)
]),
showCancelButton
:
true
,
showCancelButton
:
true
,
confirmButtonText
:
'
OK
'
,
confirmButtonText
:
'
OK
'
,
cancelButtonText
:
'
Cancel
'
,
cancelButtonText
:
'
Cancel
'
,
...
...
examples/docs/en-US/notification.md
View file @
fb4a7862
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
this.$notify({
this.$notify({
title: 'Title',
title: 'Title',
message: h('
p', { style: 'color: red
' }, 'This is a reminder')
message: h('
i', { style: 'color: teal
' }, 'This is a reminder')
});
});
},
},
...
@@ -93,7 +93,7 @@ Displays a global notification message at the upper right corner of the page.
...
@@ -93,7 +93,7 @@ Displays a global notification message at the upper right corner of the page.
this
.
$notify
({
this
.
$notify
({
title
:
'
Title
'
,
title
:
'
Title
'
,
message
:
h
(
'
p
'
,
{
style
:
'
color: red
'
},
'
This is a reminder
'
)
message
:
h
(
'
i
'
,
{
style
:
'
color: teal
'
},
'
This is a reminder
'
)
});
});
},
},
...
...
examples/docs/zh-CN/message-box.md
View file @
fb4a7862
...
@@ -60,9 +60,13 @@
...
@@ -60,9 +60,13 @@
open4() {
open4() {
const h = this.$createElement;
this.$msgbox({
this.$msgbox({
title: '消息',
title: '消息',
message: '这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容',
message: h('p', null, [
h('span', null, '内容可以是 '),
h('i', { style: 'color: teal' }, 'VNode')
]),
showCancelButton: true,
showCancelButton: true,
confirmButtonText: '确定',
confirmButtonText: '确定',
cancelButtonText: '取消',
cancelButtonText: '取消',
...
@@ -216,9 +220,13 @@
...
@@ -216,9 +220,13 @@
export
default
{
export
default
{
methods
:
{
methods
:
{
open4
()
{
open4
()
{
const
h
=
this
.
$createElement
;
this
.
$msgbox
({
this
.
$msgbox
({
title
:
'
消息
'
,
title
:
'
消息
'
,
message
:
'
这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容, 这是一段内容
'
,
message
:
h
(
'
p
'
,
null
,
[
h
(
'
span
'
,
null
,
'
内容可以是
'
),
h
(
'
i
'
,
{
style
:
'
color: teal
'
},
'
VNode
'
)
]),
showCancelButton
:
true
,
showCancelButton
:
true
,
confirmButtonText
:
'
确定
'
,
confirmButtonText
:
'
确定
'
,
cancelButtonText
:
'
取消
'
,
cancelButtonText
:
'
取消
'
,
...
@@ -268,7 +276,7 @@ import { MessageBox } from 'element-ui';
...
@@ -268,7 +276,7 @@ import { MessageBox } from 'element-ui';
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| title | MessageBox 标题 | string | — | — |
| title | MessageBox 标题 | string | — | — |
| message | MessageBox 消息正文内容 | string | — | — |
| message | MessageBox 消息正文内容 | string
/ VNode
| — | — |
| type | 消息类型,用于显示图标 | string | success/info/warning/error | — |
| type | 消息类型,用于显示图标 | string | success/info/warning/error | — |
| customClass | MessageBox 的自定义类名 | string | — | — |
| customClass | MessageBox 的自定义类名 | string | — | — |
| callback | 若不使用 Promise,可以使用此参数指定 MessageBox 关闭后的回调 | function(action, instance),action 的值为'confirm'或'cancel', instance 为 MessageBox 实例,可以通过它访问实例上的属性和方法 | — | — |
| callback | 若不使用 Promise,可以使用此参数指定 MessageBox 关闭后的回调 | function(action, instance),action 的值为'confirm'或'cancel', instance 为 MessageBox 实例,可以通过它访问实例上的属性和方法 | — | — |
...
...
examples/docs/zh-CN/notification.md
View file @
fb4a7862
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
this.$notify({
this.$notify({
title: '标题名称',
title: '标题名称',
message: h('
p', { style: 'color: red
'}, '这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案')
message: h('
i', { style: 'color: teal
'}, '这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案')
});
});
},
},
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
this
.
$notify
({
this
.
$notify
({
title
:
'
标题名称
'
,
title
:
'
标题名称
'
,
message
:
h
(
'
p
'
,
{
style
:
'
color: red
'
},
'
这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案
'
)
message
:
h
(
'
i
'
,
{
style
:
'
color: teal
'
},
'
这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案
'
)
});
});
},
},
...
...
packages/message-box/src/main.js
View file @
fb4a7862
...
@@ -29,6 +29,7 @@ const defaults = {
...
@@ -29,6 +29,7 @@ const defaults = {
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
msgboxVue
from
'
./main.vue
'
;
import
msgboxVue
from
'
./main.vue
'
;
import
merge
from
'
element-ui/src/utils/merge
'
;
import
merge
from
'
element-ui/src/utils/merge
'
;
import
{
isVNode
}
from
'
element-ui/src/utils/vdom
'
;
const
MessageBoxConstructor
=
Vue
.
extend
(
msgboxVue
);
const
MessageBoxConstructor
=
Vue
.
extend
(
msgboxVue
);
...
@@ -97,6 +98,10 @@ const showNextMsg = () => {
...
@@ -97,6 +98,10 @@ const showNextMsg = () => {
oldCb
(
action
,
instance
);
oldCb
(
action
,
instance
);
showNextMsg
();
showNextMsg
();
};
};
if
(
isVNode
(
instance
.
message
))
{
instance
.
$slots
.
default
=
[
instance
.
message
];
instance
.
message
=
null
;
}
[
'
modal
'
,
'
showClose
'
,
'
closeOnClickModal
'
,
'
closeOnPressEscape
'
].
forEach
(
prop
=>
{
[
'
modal
'
,
'
showClose
'
,
'
closeOnClickModal
'
,
'
closeOnPressEscape
'
].
forEach
(
prop
=>
{
if
(
instance
[
prop
]
===
undefined
)
{
if
(
instance
[
prop
]
===
undefined
)
{
instance
[
prop
]
=
true
;
instance
[
prop
]
=
true
;
...
...
packages/message-box/src/main.vue
View file @
fb4a7862
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
</div>
</div>
<div
class=
"el-message-box__content"
v-if=
"message !== ''"
>
<div
class=
"el-message-box__content"
v-if=
"message !== ''"
>
<div
class=
"el-message-box__status"
:class=
"[ typeClass ]"
></div>
<div
class=
"el-message-box__status"
:class=
"[ typeClass ]"
></div>
<div
class=
"el-message-box__message"
:style=
"
{ 'margin-left': typeClass ? '50px' : '0' }">
<p>
{{
message
}}
</p></div>
<div
class=
"el-message-box__message"
:style=
"
{ 'margin-left': typeClass ? '50px' : '0' }">
<slot><p>
{{
message
}}
</p></slot>
</div>
<div
class=
"el-message-box__input"
v-show=
"showInput"
>
<div
class=
"el-message-box__input"
v-show=
"showInput"
>
<el-input
v-model=
"inputValue"
@
keyup.enter.native=
"handleAction('confirm')"
:placeholder=
"inputPlaceholder"
ref=
"input"
></el-input>
<el-input
v-model=
"inputValue"
@
keyup.enter.native=
"handleAction('confirm')"
:placeholder=
"inputPlaceholder"
ref=
"input"
></el-input>
<div
class=
"el-message-box__errormsg"
:style=
"
{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">
{{
editorErrorMessage
}}
</div>
<div
class=
"el-message-box__errormsg"
:style=
"
{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">
{{
editorErrorMessage
}}
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment