Commit f724eb5797fe6091299fc4cd34f7ad1114d4ca45
1 parent
a2eb0287
update
Showing
2 changed files
with
43 additions
and
45 deletions
Show diff stats
src/components/layout/layout.vue
| 1 | <template> | 1 | <template> |
| 2 | <div :class="wrapClasses"><slot></slot></div> | 2 | <div :class="wrapClasses"><slot></slot></div> |
| 3 | - </template> | ||
| 4 | - <script> | ||
| 5 | - const prefixCls = 'ivu-layout'; | ||
| 6 | - | ||
| 7 | - export default { | ||
| 8 | - name: 'Layout', | ||
| 9 | - props: { | ||
| 10 | - className: { | ||
| 11 | - type: String, | ||
| 12 | - default: '' | ||
| 13 | - } | ||
| 14 | - }, | ||
| 15 | - data () { | ||
| 16 | - return { | ||
| 17 | - prefixCls: prefixCls, | ||
| 18 | - hasSider: false | ||
| 19 | - }; | ||
| 20 | - }, | ||
| 21 | - computed: { | ||
| 22 | - wrapClasses () { | ||
| 23 | - return [ | ||
| 24 | - `${prefixCls}`, | ||
| 25 | - this.className, | ||
| 26 | - { | ||
| 27 | - [`${prefixCls}-has-sider`]: this.hasSider | ||
| 28 | - } | ||
| 29 | - ]; | ||
| 30 | - } | ||
| 31 | - }, | ||
| 32 | - methods: { | ||
| 33 | - findSider () { | ||
| 34 | - return this.$children.some(child => { | ||
| 35 | - return child.$options._componentTag === 'Sider'; | ||
| 36 | - }); | ||
| 37 | - } | ||
| 38 | - }, | ||
| 39 | - mounted () { | ||
| 40 | - this.hasSider = this.findSider(); | ||
| 41 | - } | ||
| 42 | - }; | ||
| 43 | - </script> | ||
| 44 | \ No newline at end of file | 3 | \ No newline at end of file |
| 4 | +</template> | ||
| 5 | +<script> | ||
| 6 | + const prefixCls = 'ivu-layout'; | ||
| 7 | + | ||
| 8 | + export default { | ||
| 9 | + name: 'Layout', | ||
| 10 | + props: { | ||
| 11 | + className: { | ||
| 12 | + type: String, | ||
| 13 | + default: '' | ||
| 14 | + } | ||
| 15 | + }, | ||
| 16 | + data () { | ||
| 17 | + return { | ||
| 18 | + prefixCls: prefixCls, | ||
| 19 | + hasSider: false | ||
| 20 | + }; | ||
| 21 | + }, | ||
| 22 | + computed: { | ||
| 23 | + wrapClasses () { | ||
| 24 | + return [ | ||
| 25 | + `${prefixCls}`, | ||
| 26 | + this.className, | ||
| 27 | + { | ||
| 28 | + [`${prefixCls}-has-sider`]: this.hasSider | ||
| 29 | + } | ||
| 30 | + ]; | ||
| 31 | + } | ||
| 32 | + }, | ||
| 33 | + methods: { | ||
| 34 | + findSider () { | ||
| 35 | + return this.$children.some(child => { | ||
| 36 | + return child.$options._componentTag === 'Sider'; | ||
| 37 | + }); | ||
| 38 | + } | ||
| 39 | + }, | ||
| 40 | + mounted () { | ||
| 41 | + this.hasSider = this.findSider(); | ||
| 42 | + } | ||
| 43 | + }; | ||
| 44 | +</script> | ||
| 45 | \ No newline at end of file | 45 | \ No newline at end of file |
src/components/layout/sider.vue
| @@ -29,10 +29,8 @@ | @@ -29,10 +29,8 @@ | ||
| 29 | return { | 29 | return { |
| 30 | media: mediaQuery, | 30 | media: mediaQuery, |
| 31 | matches: false, | 31 | matches: false, |
| 32 | - on() { | ||
| 33 | - }, | ||
| 34 | - off() { | ||
| 35 | - }, | 32 | + on() {}, |
| 33 | + off() {}, | ||
| 36 | }; | 34 | }; |
| 37 | }; | 35 | }; |
| 38 | window.matchMedia = window.matchMedia || matchMediaPolyfill; | 36 | window.matchMedia = window.matchMedia || matchMediaPolyfill; |