欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ElementUI 修改默认样式

程序员文章站 2022-06-07 13:44:54
...

(一)内嵌法修改样式

通过:style修改,用于局部组件块:

<el-button :style="selfstyle">默认按钮</el-button>
<script>
	export default {
		data() {
			return {
				selfstyle: {
					color: "white",
					marginTop: "10px",
					width: "100px",
					backgroundColor: "cadetblue"
				}
			};
		}
	}
</script>

(二):class引用修改样式

通过:class修改,用于局部组件块:

<el-button :class="[selfbutton]">默认按钮</el-button>
<script>
	export default {
		data() {
			return {
				selfbutton: "self-button"
			};
		}
	}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
	.self-button {
		color: white;
		margin-top: 10px;
		width: 100px;
		background-Color: cadetblue;
	}
</style>

(三)import导入修改样式

通过import导入样式文件,若在main.js中导入css 则表示全局引用。既可以用于局部组件块也可以用于全局组件:

<el-button>和下面的el-button效果一样</el-button>
<el-button :class="[selfbutton]">默认按钮</el-button>
<script>
	import './button.css'
	export default {}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped></style>
/* button.css */ 
.el-button {
	color: white;
	margin-top: 10px;
	width: 100px;
	background-Color: cadetblue;
}
 
.self-button {
	color: white;
	margin-top: 10px;
	width: 100px;
	background-Color: cadetblue;
}
 
.self-button:hover {
	color: black;
	background-Color: whitesmoke;
}
相关标签: elemeng-ui