Commit 5776bcbf06b67a8ba955b7e5e5194826fcbdc336
1 parent
2b6e6d4c
fix #4587
Showing
2 changed files
with
17 additions
and
1 deletions
Show diff stats
examples/routers/tag.vue
| @@ -62,6 +62,13 @@ | @@ -62,6 +62,13 @@ | ||
| 62 | <br><br> | 62 | <br><br> |
| 63 | <Tag v-for="item in count" :key="item" :name="item" closable @on-close="handleClose2">标签{{ item + 1 }}</Tag> | 63 | <Tag v-for="item in count" :key="item" :name="item" closable @on-close="handleClose2">标签{{ item + 1 }}</Tag> |
| 64 | <Button icon="ios-plus-empty" type="dashed" size="small" @click="handleAdd">添加标签</Button> | 64 | <Button icon="ios-plus-empty" type="dashed" size="small" @click="handleAdd">添加标签</Button> |
| 65 | + | ||
| 66 | + <br><br><hr><br> | ||
| 67 | + <Tag :checked="checked" checkable>test</Tag> | ||
| 68 | + <Button @click="toggle"> | ||
| 69 | + Toggle | ||
| 70 | + </Button> | ||
| 71 | + <span>{{ checked }}</span> | ||
| 65 | </div> | 72 | </div> |
| 66 | </template> | 73 | </template> |
| 67 | <script> | 74 | <script> |
| @@ -69,7 +76,8 @@ | @@ -69,7 +76,8 @@ | ||
| 69 | data () { | 76 | data () { |
| 70 | return { | 77 | return { |
| 71 | show: true, | 78 | show: true, |
| 72 | - count: [0, 1, 2] | 79 | + count: [0, 1, 2], |
| 80 | + checked: true | ||
| 73 | }; | 81 | }; |
| 74 | }, | 82 | }, |
| 75 | methods: { | 83 | methods: { |
| @@ -86,6 +94,9 @@ | @@ -86,6 +94,9 @@ | ||
| 86 | handleClose2 (event, name) { | 94 | handleClose2 (event, name) { |
| 87 | const index = this.count.indexOf(name); | 95 | const index = this.count.indexOf(name); |
| 88 | this.count.splice(index, 1); | 96 | this.count.splice(index, 1); |
| 97 | + }, | ||
| 98 | + toggle() { | ||
| 99 | + this.checked = !this.checked; | ||
| 89 | } | 100 | } |
| 90 | } | 101 | } |
| 91 | }; | 102 | }; |
src/components/tag/tag.vue
| @@ -137,6 +137,11 @@ | @@ -137,6 +137,11 @@ | ||
| 137 | this.$emit('on-change', checked, this.name); | 137 | this.$emit('on-change', checked, this.name); |
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| 140 | + }, | ||
| 141 | + watch: { | ||
| 142 | + checked (val) { | ||
| 143 | + this.isChecked = val; | ||
| 144 | + } | ||
| 140 | } | 145 | } |
| 141 | }; | 146 | }; |
| 142 | </script> | 147 | </script> |
| 143 | \ No newline at end of file | 148 | \ No newline at end of file |