Skip to content

Commit

Permalink
fix: watch props change
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Jul 2, 2020
1 parent 8d13752 commit 0fd660c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/vue/src/select2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export class Select2 extends Vue {
mounted() {
this.searchInputElement = this.$refs.searchInput as HTMLElement
this.resultsElement = this.$refs.results as HTMLElement

this.$watch('value', () => {
const option = common.getOptionsByValue(this.data, this.value, this.multiple)
this.option = option
if (!Array.isArray(option)) {
this.hoveringValue = this.value as string | undefined
}
})
}

beforeDestroy() {
Expand Down

0 comments on commit 0fd660c

Please sign in to comment.