【发布时间】:2020-10-07 20:17:18
【问题描述】:
我正在开发的 Quasar 应用程序允许拍照并在输入字段中添加一些文本。成功发送图片后,对话框出现并提供 2 个按钮,一个是“Take another piture”(另一个重定向到另一个页面):
// text input field
<div class="row justify-center q-ma-md">
<q-input
v-model="post.caption"
ref="inputCaption"
hint="Please enter at least 4 characters."
:rules="[required(), minLength()]"
clearable
label="Caption *"
dense
class="col col-sm-6" />
</div>
// Dialog buttons
<q-dialog v-model="savedSuccessfully">
[...]
<q-card-actions align="right" class="text-primary">
<q-btn unelevated rounded color="secondary" label="Take another photo" @click="resetCanvas" />
<q-btn unelevated rounded color="primary" label="Go to postings" @click="goToPostings" />
</q-card-actions>
“resetCanvas”功能不仅重置图像画布,还重置输入字段不幸的是resetValidation() - 根据 Quasar 的文档应该可以完成这项工作 - 输入字段仍然被识别为脏:
resetCanvas() {
[...]
this.$refs.inputCaption.resetValidation()
this.$refs.inputCaption.isDirty = false
},
我什至在重置脚本中添加了this.$refs.inputCaption.isDirty = false,但无济于事。 (见截图)
如何在重置后正确清除输入字段?
【问题讨论】: