Currently, I am in the process of transitioning from the options API to the composition API in Vue.
Within the code block below, I am attempting to implement two-way binding.
I am utilizing the ant-design-vue
library for a slider input and trying to bind the slider value to an input field.
<template>
<div>
<a-row>
<a-col :span="12">
<a-slider v-model="inputValue1" :min="1" :max="20" />
</a-col>
<a-col :span="4">
<a-input-number
v-model="inputValue1"
:min="1"
:max="20"
style="marginleft: 16px"
/>
</a-col>
</a-row>
</div>
</template>
<script>
import { ref } from "vue";
export default {
setup() {
let inputValue1 = ref(8);
return { inputValue1 };
},
};
</script>
In the provided code snippet, the value of inputValue1
does not update when inspected using the Vue Dev Tools.
How can I achieve two-way binding with Vue 3 Composition API?
Sandbox link: https://stackblitz.com/edit/vue-pchhub?file=src%2FApp.vue