forked from james090500/vue-tagsinput
-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.vue
39 lines (32 loc) · 901 Bytes
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<template>
<div class="container mx-auto">
<button @click="openShowTagSelector()">SHOW TAGS SELECTOR</button>
<div class="input-block">
<TagSelector
ref="tagSelectRef"
v-show="showTagSelector"
@apply="applyTags"
@closeTagSelector="showTagSelector = false"
/>
APPLIED TAGS: {{ previousSelectedTags.length }}
</div>
</div>
</template>
<script setup>
import {
ref, toRaw
} from 'vue'
import TagSelector from './components/TagSelector.vue'
const tagSelectRef = ref(null)
const showTagSelector = ref(false)
const previousSelectedTags = ref([])
const applyTags = (selectedTags) => {
// tagSelectRef.value = false
previousSelectedTags.value = selectedTags
showTagSelector.value = false
}
const openShowTagSelector = () => {
tagSelectRef.value.init(toRaw(previousSelectedTags.value))
showTagSelector.value = true
}
</script>