Ant-Design-Vue $nitication与$message全局配置


使用ant里这两个组件需要进行全局配置:

import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false;
//注入全局属性$message
import { message,notification } from 'ant-design-vue'
Vue.prototype.$message = message;
Vue.prototype.$notification = notification;
message.config({
    duration: 2,
});
new Vue({
  render: h => h(App),
}).$mount('#app')

null

在Main.js,在Vue的原型链增加这两个属性。在其他子组件里就可以通过$引用了。

this.$message.info("提交完成!")

 this.$notification.open({
                    message: '这是一条通知!',
                    description: '这是描述内容!.',
                    icon: <a-icon type="smile" style="color: #108ee9"/>,
                    onClick: () => {
                        console.log('你点击了通知');
                    },
                });

null


文章作者: 2winter
文章链接: https://2winter.com
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 2winter !
  目录