Typescript Vue.js+;为什么v型不被认为是价值? 问题
我在Vue.js+TypeScript项目中遇到以下错误:Typescript Vue.js+;为什么v型不被认为是价值? 问题,typescript,vue.js,vuejs2,Typescript,Vue.js,Vuejs2,我在Vue.js+TypeScript项目中遇到以下错误: <my-input> misses props: value MyFirstView.vue 现在,我想以以下方式使用myInput组件: <template> <div> <my-input v-model="myValue" /> </div> </template> <script lang="ts&qu
<my-input> misses props: value
MyFirstView.vue
现在,我想以以下方式使用myInput
组件:
<template>
<div>
<my-input v-model="myValue" />
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import MyInput from '@/components/MyInput.vue';
@Component({
components: { MyInput }
})
export default class MyFirstView extends Vue {
myValue = 'my test value';
}
</script>
显然,我用v-model
关键字设置了value
属性,对吗?但是为什么我会得到值
属性不会被设置的错误呢
当我将required
关键字更改为false
时,错误消失,但这不是正确的解决方案,对吗?因为我希望值
属性是必需的
使用了IDE:VSCode和ESLint+Prettier以及Vue.js 2.6.11这是Vetur中的一个bug,在将Vetur更新到v0.27.2或更高版本时修复了。我也收到了这个错误,但仅在VSCode中。我在命令行上的
npm run build
或npm run serve
中没有看到此错误。@smeier_ec那么我的代码实际上是正确的?我会这么说。我不知道为什么VSCode会突然显示这些错误消息(我很确定几周前没有)。
<template>
<div>
<my-input v-model="myValue" />
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import MyInput from '@/components/MyInput.vue';
@Component({
components: { MyInput }
})
export default class MyFirstView extends Vue {
myValue = 'my test value';
}
</script>
<my-input v-bind:value="myValue" v-on:input="myValue = $event" />