在使用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 });