我发现了这个错误并阻止了我的Web应用程序。
2:32:22 PM [vite] Internal server error: v-model cannot be used on a prop, because local prop bindings are not writable.
Use a v-bind binding combined with a v-on listener that emits update:x event instead.
Plugin: vite:vue
File: /Users/julapps/web/myapp/src/components/switch/AudienceTimerSlide.vue
字符串
我想让定时器数据成为数据模型(可编辑)和组件 prop 的默认值。为什么这不工作?我在vuejs非常新,我如何解决这个问题?请帮助...
<template>
----
<div class="field-body">
<div class="field">
<div class="control">
<input @keypress.enter="save" v-model="timer" type="number" class="input is-normal">
</div>
</div>
</div>
-----
</template>
<script>
export default {
props:['id', 'timer'],
setup(props, context){
-----
const save = async() => {
// save form
}
return {
}
}
}
</script>
型
4条答案
按热度按时间1sbrub3j1#
你必须改变
defineProps(['question', 'choices'])
到
const props=defineProps(['question', 'choices'])
个在类似
<TextInput :text="props.question" ></TextInput>
的脚本中调用props.question
mefy6pfw2#
字符串
改变
型
参考:https://learnvue.co/articles/v-model-guide
qxsslcnc3#
prop 是只读的单向数据流
使用内部数据属性,初始值为
timer
。如下所示:字符串
和
型
或者将
v-model
替换为v-bind:value
&emit
事件型
就像这样:
型
ev7lccsx4#
你可以用computed function来实现:
字符串
并将其用于输入:
第一个月