在使用iview 的Message與Notice組件時,能夠對提示框的顯示位置與顯示時長進行配置。php
iview提供了兩個配置屬性。分別是:vue
能夠對這兩個組件進行全局配置:bash
簡單點//在某個組件中全局配置,只須要在mouted()鉤子函數中寫入 mounted() { this.$Message.config({ top: 100, duration: 3 }); this.$Notice.config({ top: 100, duration: 3 }); } //在整個項目中全局配置,須要在main.js中寫入 Vue.prototype.$Message.config({ top: 100, duration: 3 }); Vue.prototype.$Notice.config({ top: 50, duration: 3 });
import iView from 'iview' Vue.use(iView)
this.$Message.info('This is a info tip'); this.$Message.success('This is a success tip'); this.$Message.warning('This is a warning tip'); this.$Message.error('This is an error tip');
import { Message } from 'iview' Message.info('hello'); Message.success('hello'); Message.warning('hello'); Message.error('hello');
main.jsiview
Vue.prototype.$Message.config({ top: 70, duration:2 });
局部配置中設置高度無效函數
this.$Message.info({ content: 'I'll be gone in 10 seconds', duration: 10, closable: true });