Skip to content

Instantly share code, notes, and snippets.

@jarrodhroberson
Created June 6, 2023 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarrodhroberson/b6cb706a73e2ac856f8c9330a0eb2d33 to your computer and use it in GitHub Desktop.
Save jarrodhroberson/b6cb706a73e2ac856f8c9330a0eb2d33 to your computer and use it in GitHub Desktop.
Reactive Component Vue 3
<script setup>
import { ref } from 'vue'
import CustomInput from './CustomInput.vue'
const messages = ref([])
messages.value.push({channel: { title: "Jarrod Roberson"}})
messages.value.push({channel: { title: "Julian Roberson"}})
messages.value.push({channel: { title: "Sebastian Roberson"}})
messages.value.push({channel: { title: "Valentino Roberson"}})
</script>
<template>
<div v-for='(message, idx) in messages' :key='idx'>
<CustomInput v-model="messages[idx].channel.title" /> {{ message.channel.title }}
</div>
</template>
<script setup>
defineProps(['modelValue'])
defineEmits(['update:modelValue'])
</script>
<template>
<input
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
/>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment