feat:换肤效果
Showing
4 changed files
with
35 additions
and
3 deletions
src/directive/theme.js
0 → 100644
| 1 | export const theme = { | ||
| 2 | bind: function (el, binding, vnode) { | ||
| 3 | setEleStyleColorAttribute(el, binding); | ||
| 4 | }, | ||
| 5 | update: function (el, binding, vnode) { | ||
| 6 | setEleStyleColorAttribute(el, binding); | ||
| 7 | }, | ||
| 8 | componentUpdated: function (el, binding, vnode) { | ||
| 9 | setEleStyleColorAttribute(el, binding); | ||
| 10 | } | ||
| 11 | } | ||
| 12 | |||
| 13 | function setEleStyleColorAttribute (el, binding) { | ||
| 14 | const { name, value, arg, expression, modifiers } = binding; | ||
| 15 | const { background, font, border } = modifiers; | ||
| 16 | if (background) el.style['background-color'] = value; | ||
| 17 | if (font) el.style.color = value; | ||
| 18 | if (border) el.style['border-color'] = value; | ||
| 19 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <template> | 1 | <template> |
| 2 | <div class="navbar"> | 2 | <div class="navbar" v-theme.background="mTheme"> |
| 3 | <div class="logo"> | 3 | <div class="logo"> |
| 4 | <img v-if="logo" :src="logo" class="header-logo"> | 4 | <img v-if="logo" :src="logo" class="header-logo"> |
| 5 | </div> | 5 | </div> |
| ... | @@ -94,7 +94,7 @@ export default { | ... | @@ -94,7 +94,7 @@ export default { |
| 94 | overflow: hidden; | 94 | overflow: hidden; |
| 95 | position: relative; | 95 | position: relative; |
| 96 | background: #fff; | 96 | background: #fff; |
| 97 | background: linear-gradient(270deg, #148CEE 0%, #1870E3 100%); | 97 | // background: linear-gradient(270deg, #148CEE 0%, #1870E3 100%); //默认颜色 |
| 98 | box-shadow: 0 1px 0px rgba(0, 21, 41, 0.08); | 98 | box-shadow: 0 1px 0px rgba(0, 21, 41, 0.08); |
| 99 | display: flex; | 99 | display: flex; |
| 100 | align-items: center; | 100 | align-items: center; | ... | ... |
| ... | @@ -6,7 +6,12 @@ import 'normalize.css/normalize.css' // a modern alternative to CSS resets | ... | @@ -6,7 +6,12 @@ import 'normalize.css/normalize.css' // a modern alternative to CSS resets |
| 6 | import Element from 'element-ui' | 6 | import Element from 'element-ui' |
| 7 | import './styles/element-variables.scss' | 7 | import './styles/element-variables.scss' |
| 8 | import '@/styles/index.scss' | 8 | import '@/styles/index.scss' |
| 9 | import Base from './components/Base/base' | 9 | import Base from './components/Base/base' // 全局组件引入 |
| 10 | import mixin from '@/utils/mixin/theme.js' | ||
| 11 | Vue.mixin(mixin); | ||
| 12 | |||
| 13 | import { theme } from "@/directive/theme.js" | ||
| 14 | Vue.directive("theme", theme) | ||
| 10 | 15 | ||
| 11 | import './image/icons' // icon | 16 | import './image/icons' // icon |
| 12 | import store from './store' | 17 | import store from './store' | ... | ... |
-
Please register or sign in to post a comment