Commit 71699f6b29638b46c041c06ef340a5a96176c18c

Authored by 梁灏
1 parent 9a9e103f

optimize Checkbox in single type without slot

optimize Checkbox in single type without slot
src/components/checkbox/checkbox.vue
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 v-model="checked" 18 v-model="checked"
19 @change="change"> 19 @change="change">
20 </span> 20 </span>
21 - <slot><span>{{ value }}</span></slot> 21 + <slot v-if="showSlot"><span v-el:slot>{{ value }}</span></slot>
22 </label> 22 </label>
23 </template> 23 </template>
24 <script> 24 <script>
@@ -42,7 +42,8 @@ @@ -42,7 +42,8 @@
42 return { 42 return {
43 model: [], 43 model: [],
44 selected: false, 44 selected: false,
45 - group: false 45 + group: false,
  46 + showSlot: true
46 } 47 }
47 }, 48 },
48 computed: { 49 computed: {
@@ -75,6 +76,9 @@ @@ -75,6 +76,9 @@
75 ready () { 76 ready () {
76 if (!this.group) { 77 if (!this.group) {
77 this.updateModel(); 78 this.updateModel();
  79 + if (this.$els.slot && this.$els.slot.innerHTML === '') {
  80 + this.showSlot = false;
  81 + }
78 } 82 }
79 }, 83 },
80 methods: { 84 methods: {
test/routers/radio.vue
@@ -141,6 +141,8 @@ @@ -141,6 +141,8 @@
141 <Breadcrumb-item href="/components/breadcrumb">Components</Breadcrumb-item> 141 <Breadcrumb-item href="/components/breadcrumb">Components</Breadcrumb-item>
142 <Breadcrumb-item>Breadcrumb</Breadcrumb-item> 142 <Breadcrumb-item>Breadcrumb</Breadcrumb-item>
143 </Breadcrumb> 143 </Breadcrumb>
  144 + <br><br>
  145 + <Checkbox :checked.sync="single"></Checkbox>
144 </template> 146 </template>
145 <script> 147 <script>
146 import { Radio, Alert, Icon, Collapse, Button, Checkbox, Switch, InputNumber, Breadcrumb, LoadingBar } from 'iview'; 148 import { Radio, Alert, Icon, Collapse, Button, Checkbox, Switch, InputNumber, Breadcrumb, LoadingBar } from 'iview';
@@ -172,6 +174,7 @@ @@ -172,6 +174,7 @@
172 }, 174 },
173 data () { 175 data () {
174 return { 176 return {
  177 + single: false,
175 radio: false, 178 radio: false,
176 radioGroup: '段模', 179 radioGroup: '段模',
177 activeKey: [1,2], 180 activeKey: [1,2],