2

I want to use the new Vue syntax from https://github.com/vuejs/vue-class-component. Unfortunately, I have trouble accessing the value that's passed with v-model. I can instead declare a @value property to pass the value but that seems a bit inconsistent given that there are a lot of existing uses of v-model in my codebase.

<template>
    <div>
        {{value}}
    </div>
</template>

<script lang="ts">
import Vue from "vue"
import Component from "vue-class-component"
import { Prop } from "vue-property-decorator"

@Component
export default class Display extends Vue {
    @Prop() value!: string
    // lifecycle hook
    mounted() {alert("The value is " + this.value)}
}
</script>

The current code can be accessed with:

<Display :value="myVar"/>

I'd like to access via:

<Display v-model="myVar"/>
Christian
  • 25,249
  • 40
  • 134
  • 225

0 Answers0