当前第2页 返回上一页
1 2 3 4 5 6 7 8 | <p>
<el-button>默认按钮</el-button>
<el-button type= "primary" >主要按钮</el-button>
<el-button type= "success" >成功按钮</el-button>
<el-button type= "info" >信息按钮</el-button>
<el-button type= "warning" >警告按钮</el-button>
<el-button type= "danger" >危险按钮</el-button>
</p>
|
第二种方法: 直接修改element样式变量
在项目中直接修改element的样式变量,(前提是你的文档也是使用scss编写)
一、首先用vue-cli安装一个新项目:
1,安装vue:
2,在项目目录下安装vue-cli:
3,基于webpack建立新项目( vue-project)
1 | vue init webpack vue-project
|
4,依次输入以下命令行,运行vue-project
1 2 3 | cd vue-project
npm i
npm run dev
|
二、安装elementUI以及sass-loader,node-sass(项目中使用scss编写需要依赖的插件)
1,安装element-ui
2,安装sass-loader,node-sass
1 | npm i sass-loader node-sass -D
|
在这里说一下,不需要配置webpack.base.conf.js文件,vue-loader会根据不同类型文件来配置相应loader来打包我们的样式文件(感兴趣的可看下vue-loader的核心代码)
三、改变element样式变量
1.在src下建立element-variables.scss文件(名字可以自定义),写入如下代码:
1 2 3 4 5 | $--color-primary: teal;
$--font-path: '../node_modules/element-ui/lib/theme-chalk/fonts' ;
@import "../node_modules/element-ui/packages/theme-chalk/src/index" ;
|
2.在入口文件main.js中引入上面的文件即可
1 2 3 4 | import Vue from 'vue'
import Element from 'element-ui'
import './element-variables.scss'
Vue. use (Element)
|
看下效果吧,在文件里引入些样式看看,如button
1 2 3 4 5 6 7 8 | <p>
<el-button>默认按钮</el-button>
<el-button type= "primary" >主要按钮</el-button>
<el-button type= "success" >成功按钮</el-button>
<el-button type= "info" >信息按钮</el-button>
<el-button type= "warning" >警告按钮</el-button>
<el-button type= "danger" >危险按钮</el-button>
</p>
|
默认的颜色已经变为我们自定义的了,有其他的改变在element-variable.scss文件中改变变量即可
相关推荐:
elementui的默认样式修改方法分享
vue 2.0和elementUI实现面包屑导航栏方法代码
利用vue+elementUI部分引入组件的实现方法
以上就是Vue的elementUI实现自定义主题的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
js如何实现自定义鼠标右击菜单
html怎样自定义标签
html5自定义遮罩的实现代码分享
elementui和bootstrap区别
html5在canvas中实现自定义路径动画详解
在canvas中如何实现自定义路径动画?
利用html5自定义实现播放器代码分享
webstorm怎么自定义用户设置
h5中如何获取和设置自定义属性
jquery自定义函数应用以及解析
更多相关阅读请进入《elementui》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » Vue的elementUI实现自定义主题