# 自定义主题
注意
默认请求网络资源,如果是在没有网络的环境必须提供本地文件地址.
点击查看代码
<!-- @format -->
<template>
<div>
<el-row class="m-5">
<el-button plain>朴素按钮</el-button>
<el-button type="primary" plain>主要按钮</el-button>
<el-button type="success" plain>成功按钮</el-button>
<el-button type="info" plain>信息按钮</el-button>
<el-button type="warning" plain>警告按钮</el-button>
<el-button type="danger" plain>危险按钮</el-button>
</el-row>
<el-row class="m-5">
<el-button round>圆角按钮</el-button>
<el-button type="primary" round>主要按钮</el-button>
<el-button type="success" round>成功按钮</el-button>
<el-button type="info" round>信息按钮</el-button>
<el-button type="warning" round>警告按钮</el-button>
<el-button type="danger" round>危险按钮</el-button>
</el-row>
<el-row class="m-5">
<el-button icon="el-icon-search" circle></el-button>
<el-button type="primary" icon="el-icon-edit" circle></el-button>
<el-button type="success" icon="el-icon-check" circle></el-button>
<el-button type="info" icon="el-icon-message" circle></el-button>
<el-button type="warning" icon="el-icon-star-off" circle></el-button>
<el-button type="danger" icon="el-icon-delete" circle></el-button>
</el-row>
<div class="flex items-center m-5">
<z-theme url="https://unpkg.com/element-ui@2.15.13/lib/theme-chalk/index.css" v-model="colorConfig"></z-theme>
当前颜色:{{ colorConfig.primary }}
<el-button type="primary" class="ml-10" @click="changeColor">改变成功按钮颜色</el-button>
</div>
</div>
</template>
<script>
export default {
name: 'zThemeDemo',
data() {
return {
colorConfig: {
primary: '#004082',
success: '#00661A',
info: '#BB4800',
warning: '#E6A23C',
danger: '#F56C6C'
}
};
},
methods: {
changeColor() {
this.colorConfig = {
...this.colorConfig,
success: '#F56000'
};
}
}
};
</script>
<style scoped></style>
属性 | 描述 | 默认值 |
---|---|---|
v-model/value | 颜色配置,可以对所有颜色进行配置,如果传递一个字符串,默认设置为primary 颜色.如果需要对其他颜色进行更改,需要将颜色值全部覆盖 | #409EFF 必须为16进制颜色 全部颜色默认值 {"primary":"#409EFF", "success":"#67C23A", "info":"#909399", "warning":"#E6A23C", "danger":"#F56C6C"} |
url | css资源地址 | https://unpkg.com/element-ui@2.15.13/lib/theme-chalk/index.css |
caches | 是否对css资源进行缓存,将会缓存到 localStorage 中 | true |