在main.js :
import ElementPlus from 'element-plus';
import 'element-plus/theme-chalk/index.css';
import 'element-plus/dist/index.css'
// import locale from 'element-plus/lib/locale/lang/zh-cn'
将 createApp(App).mount('#app') 替换为:
createApp(App).use(ElementPlus, { locale }).mount('#app') 或
createApp(App).use(ElementPlus).mount('#app')
即可在.vue中直接使用:
import { ElMessage } from "element-plus";
...
ElMessage.info(info);