JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vuex@4.0.0-beta.4/dist/vuex.global.js"></script>
<script src="https://unpkg.com/vue-router@4.0.0-beta.3/dist/vue-router.global.js"></script>
<div id="app">
<h1>{{ message.test }}</h1>
<child v-model="message"></child>
</div>
JavaScript
const { createApp, reactive, computed } = Vue;
const child = {
template: `<input v-model="message.test" type="text" />`,
props: {
modelValue: {
type: Object,
default: () => ({}),
},
},
emits: ['update:modelValue'],
setup(props, { emit }) {
const message = computed({
get: () => props.modelValue,
// No set() ?
// This is a one-way computed, yet the data is still emitted to the parent component.
});
return { message };
}
};
createApp({
components: { child },
setup() {
const message = reactive({ test: 'Karamazov' });
return { message };
}
}).mount('#app');