使用Element-Plus
组件库中的ElNotification
组件时不显示弹窗。
导致原因:
我在使用webpack
的自动导入功能,但是我忘记了,用ElNotification
时重复手动导入了一次:
<template>
<div>
</div>
</template>
<script>
import checkUpdate from "../../function/CheckUpdate";
import Config from "../../function/Config";
import { ElNotification } from 'element-plus'
export default {
mounted() {
this.showNotify();
},
methods: {
async showNotify() {
await checkUpdate().then((res) => {
if (res.need) {
ElNotification({
title: "titletitle",
type: "warning",
message: "msgmsgmsg",
});
}
});
},
},
};
</script>
<style scoped>
</style>
解决方法:
将手动导入的代码删除
import { ElNotification } from 'element-plus'
这时通知组件就可以正常显示了: