Element: How to set Message component's default options

Created on 8 Jun 2017  ·  3Comments  ·  Source: ElemeFE/element

Existing Component

yes

Component Name

Message

Description

I want to set showClose:true and duration:1000 to Message's default option, so that i won't set the option of every call.

All 3 comments

You can write your own wrapper function.

@Xcorpio 你解决这个问题了吗?
我想到一个笨办法

在 main.js 中

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
Vue.prototype.$mes = option => Vue.prototype.$message({showClose: true, ...option})
Vue.prototype.$mes.success = mes => Vue.prototype.$message.success({showClose: true, message: mes})

希望对你有帮助!
当然,如果你已经找到更好的方法,希望 @ 我一下

我去, 都2020年了, 这问题还没办法啊?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akaylh picture akaylh  ·  3Comments

FranzSkuffka picture FranzSkuffka  ·  3Comments

chenzhe-pro picture chenzhe-pro  ·  3Comments

yorululu picture yorululu  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments