element-ui Message消息提示文字换行
直接上代码
pullMsgWithLine(title,msg) {
// \r\n 后台传上来的换行符,这里做分隔符
let returnMsgList = msg.split(’\r\n’);
let newDatas = [],h = this.
c
r
e
a
t
e
E
l
e
m
e
n
t
;
n
e
w
D
a
t
a
s
.
p
u
s
h
(
′
导
入
文
件
′
+
t
i
t
l
e
+
′
失
败
!
′
)
;
/
/
循
环
数
据
依
次
放
入
最
终
数
据
中
f
o
r
(
c
o
n
s
t
i
i
n
r
e
t
u
r
n
M
s
g
L
i
s
t
)
i
f
(
i
!
=
′
0
′
)
n
e
w
D
a
t
a
s
.
p
u
s
h
(
h
(
′
p
′
,
n
u
l
l
,
r
e
t
u
r
n
M
s
g
L
i
s
t
[
i
]
)
)
t
h
i
s
.
createElement; newDatas.push('导入文件'+ title + ' 失败!'); // 循环数据 依次放入最终数据中 for (const i in returnMsgList) { if(i!='0') newDatas.push(h('p', null, returnMsgList[i])) } this.
createElement;newDatas.push(′导入文件′+title+′失败!′);//循环数据依次放入最终数据中for(constiinreturnMsgList)if(i!=′0′)newDatas.push(h(′p′,null,returnMsgList[i]))this.message.error( newDatas);
},
去博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片
.
// An highlighted block
pullMsgWithLine(title,msg) {
// \r\n 后台传上来的换行符,这里做分隔符
let returnMsgList = msg.split('\r\n');
let newDatas = [],h = this.$createElement;
newDatas.push('导入文件'+ title + ' 失败!');
// 循环数据 依次放入最终数据中
for (const i in returnMsgList) {
if(i!='0') //第一行空行过滤
newDatas.push(h('p', null, returnMsgList[i]))
}
this.$message.error( newDatas);
},
this.pullMsgWithLine('导入失败',msg1);