vue3.0、cli4项目引入element plus
2022-10-08 17:22:18
195
{{single.collect_count}}

element团队为新版的 vue-cli4 准备了相应的 Element Plus 插件


安装依赖

npm install element-plus --save

main.js全局引入,样式文件需要单独引入

import { createApp } from 'vue'import ElementPlus from 'element-plus';import 'element-plus/lib/theme-chalk/index.css';import App from './App.vue';const app = createApp(App)app.use(ElementPlus)app.mount('#app')

按需引入需要借助babel-plugin-import插件,详情见官网




自定义样式变量:

如果你的项目也使用了 SCSS,那么可以直接在项目中改变 Element Plus 的样式变量,否则参考官网的其他方法。
在src中创建element-variables.scss

/* 所有变量在这里改后生效 *//* 改变主题色变量 */$--color-primary: teal;/* 改变 icon 字体路径变量,必需 */$--font-path: '~element-plus/lib/theme-chalk/fonts';@import "~element-plus/packages/theme-chalk/src/index";

main.js中引入

import Vue from 'vue'import ElementPlus from 'element-plus'import './element-variables.scss'import App from './App.vue';const app = createApp(App)app.use(ElementPlus)
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}