HTML怎么引入ElementPlus中的ELMessage
时间: 2024-05-12 22:18:35 浏览: 114
要在 HTML 中引入 ElementPlus 的 ELMessage,需要先引入 ElementPlus 的 CSS 和 JavaScript 文件。可以按照以下步骤操作:
1. 在 HTML 文件中引入 ElementPlus 的 CSS 文件:
```html
<link rel="stylesheet" href="https://unpkg.com/element-plus/lib/theme-chalk/index.css">
```
2. 在 HTML 文件中引入 ElementPlus 的 JavaScript 文件:
```html
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/element-plus@next"></script>
```
注意:上面的代码中,Vue.js 的版本需要和 ElementPlus 的版本兼容,可以根据具体情况进行选择。
3. 在 HTML 文件中使用 ELMessage 组件:
```html
<template>
<el-button type="primary" @click="showMessage">显示消息</el-button>
</template>
<script>
import { ElMessage } from 'element-plus';
export default {
methods: {
showMessage() {
ElMessage({
message: '操作成功',
type: 'success',
});
},
},
};
</script>
```
上面的代码中,通过 import 引入 ELMessage 组件,然后在 Vue.js 的组件中使用。在点击按钮时,调用 showMessage 方法,弹出一个消息提示框。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)