Skip to content

Commit

Permalink
Merge pull request #521 from DaoCloud/fix/setting-layout-v-show-issue
Browse files Browse the repository at this point in the history
fix(setting-layout): 修复 v-show 对 setting-layout 不起作用的问题
  • Loading branch information
CIN authored Jul 25, 2018
2 parents b92e810 + 13a97ad commit 56c7bda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/routers/setting-layout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<button class="dao-btn blue" @click="show = !show">切换 Layout</button>
<dao-setting-layout v-if="show">
<dao-setting-layout v-if="show" class="test-class">
<template slot="layout-title">大标题</template>
<template slot="layout-title-helper">大标题一定要有,表单必有头</template>
<dao-setting-section>
Expand Down Expand Up @@ -66,13 +66,15 @@
</template>
<script>
export default {
data () {
data() {
return {
show: true,
};
},
};
</script>
<style lang="scss">
.test-class {
color: red;
}
</style>
8 changes: 7 additions & 1 deletion src/components/dao-setting-layout/dao-setting-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export default {
footerSlot,
]) : '';

return h('div', { class: 'dao-setting-layout' }, [
return h('div', {
...context.data,
// 此处不用 `class: 'dao-setting-layout'` 的原因为:
// dao-setting-layout 这个类会覆盖外部传入的动态绑定 class
// 导致在组件外部传入 :class="['testClass']" 类似用法会失效
staticClass: `dao-setting-layout ${context.data.staticClass}`,
}, [
LayoutTitle, defaultSlot, Footer,
]);
},
Expand Down

0 comments on commit 56c7bda

Please sign in to comment.