-
Notifications
You must be signed in to change notification settings - Fork 336
docs(tag-input): add example #3975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" clearable></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive, ref } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
|
|
||
| const placeholder = ref('please enter a tag') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" clearable></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| placeholder: 'please enter a tag' | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :min-collapsed-num="minCollapsedNum"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive, ref } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const minCollapsedNum = ref(5) | ||
| const placeholder = ref('please enter a tag') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :min-collapsed-num="minCollapsedNum"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| placeholder: 'please enter a tag', | ||
| minCollapsedNum: 5 | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <template> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div class="tiny-tag-input-demo"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>disabled: </span><tiny-tag-input v-model="data" :placeholder="placeholder" disabled></tiny-tag-input> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>readonly:</span><tiny-tag-input v-model="data1" :placeholder="placeholder" readonly></tiny-tag-input> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor docs polish: make the two labels consistent ( 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <script setup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { reactive } from 'vue' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TinyTagInput } from '@opentiny/vue' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data1 = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "disabled-readonly-composition-api.vue" -type fRepository: opentiny/tiny-vue Length of output: 138 🏁 Script executed: cat -n examples/sites/demos/pc/app/tag-input/disabled-readonly-composition-api.vueRepository: opentiny/tiny-vue Length of output: 829 🌐 Web query:
💡 Result: Short answer
Why and how (concise)
Quick examples
Recommendation
Sources Blocker: For two-way binding with Fix<script setup>
-import { reactive } from 'vue'
+import { ref } from 'vue'
import { TinyTagInput } from '@opentiny/vue'
-const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'])
-const data1 = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'])
+const data = ref(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'])
+const data1 = ref(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'])
+const placeholder = ref('please enter a tag')
</script>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <style scoped> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .tiny-tag-input-demo .tiny-tag-input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| margin-bottom: 20px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||
| <template> | ||||||||||
| <div class="tiny-tag-input-demo"> | ||||||||||
| <span>disabled: </span><tiny-tag-input v-model="data" :placeholder="placeholder" disabled></tiny-tag-input> | ||||||||||
| <span>readonly:</span><tiny-tag-input v-model="data1" :placeholder="placeholder" readonly></tiny-tag-input> | ||||||||||
|
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix punctuation inconsistency in label. Line 3 uses an English colon 📝 Suggested fix <span>disabled: </span><tiny-tag-input v-model="data" :placeholder="placeholder" disabled></tiny-tag-input>
- <span>readonly:</span><tiny-tag-input v-model="data1" :placeholder="placeholder" readonly></tiny-tag-input>
+ <span>readonly: </span><tiny-tag-input v-model="data1" :placeholder="placeholder" readonly></tiny-tag-input>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| </div> | ||||||||||
| </template> | ||||||||||
|
|
||||||||||
| <script> | ||||||||||
| import { TinyTagInput } from '@opentiny/vue' | ||||||||||
|
|
||||||||||
| export default { | ||||||||||
| components: { | ||||||||||
| TinyTagInput | ||||||||||
| }, | ||||||||||
| data() { | ||||||||||
| return { | ||||||||||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||||||||||
| data1: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||||||||||
| placeholder: 'please enter a tag' | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| </script> | ||||||||||
|
|
||||||||||
| <style scoped> | ||||||||||
| .tiny-tag-input-demo .tiny-tag-input { | ||||||||||
| margin-bottom: 20px; | ||||||||||
| } | ||||||||||
| </style> | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" draggable></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" draggable></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'] | ||
| } | ||
| } | ||
| } | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :max="max"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const max = 5 | ||
| const placeholder = 'please enter a tag' | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :max="max"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| max: 5, | ||
| placeholder: 'enter up to 5 tags' | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder"> | ||
| <template #prefix> | ||
| <span>prefix:</span> | ||
| </template> | ||
| <template #suffix> | ||
| <span>suffix</span> | ||
| </template> | ||
| </tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive, ref } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const placeholder = ref('please enter a tag') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder"> | ||
| <template #prefix> | ||
| <span>prefix:</span> | ||
| </template> | ||
| <template #suffix> | ||
| <span>suffix</span> | ||
| </template> | ||
| </tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| placeholder: 'please enter a tag' | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :separator="separator"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive, ref } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const placeholder = ref('please enter a tag') | ||
| const separator = ref(',') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder" :separator="separator"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| placeholder: 'please enter a tag', | ||
| separator: ',' | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 134
🏁 Script executed:
cat "examples/sites/demos/pc/app/tag-input/clearable-tag-composition-api.vue"Repository: opentiny/tiny-vue
Length of output: 534
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 1323
🏁 Script executed:
Repository: opentiny/tiny-vue
Length of output: 1564
🌐 Web query:
Vue 3 v-model with reactive() vs ref() composition api💡 Result:
Short summary — key points and practical guidance:
ref vs reactive (general)
v-model implications
Practical recommendations
References
🏁 Script executed:
head -20 "examples/sites/demos/pc/app/tag-input/basic-usage-composition-api.vue"Repository: opentiny/tiny-vue
Length of output: 730
Use
ref()instead ofreactive()forv-modelbindings.In Vue 3 Composition API,
v-model="data"compiles to an assignment handler (@update:modelValue="value => { data = value }"). Sincedatais declared asconst data = reactive([...]), reassignment is blocked. When TinyTagInput emits a new array, the binding fails silently. Useref()instead:<script setup> import { TinyTagInput } from '@opentiny/vue' -import { reactive, ref } from 'vue' +import { ref } from 'vue' -const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) +const data = ref(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) const placeholder = ref('please enter a tag') </script>📝 Committable suggestion
🤖 Prompt for AI Agents