使用Framework7vue(当前版本4.4.3),我试图在submit上验证一个表单。我找到了以下代码:http://forum.framework7.io/t/solved-how-to-validate-form-using-button-v2/1889
$$('.save').on('click', function(e){
e.preventDefault();
if (!$$('#form-name')[0].checkValidity()) {
console.log('Check Validity!');
} else {
//ajax request here
return false;
}});
然而,我很难把它翻译成在vue工作。注销表单对象,我看不到checkValidity选项.
我已经能够通过
const formData = this.$f7.form.convertToData('#ajaxForm')我正在使用框架7的输入。
<f7-list >
<f7-list-input v-for="field in form"
:name="field.name"
:value="field.value"
@input="field.value = $event.target.value"
:label="field.label"
:type="field.type"
:placeholder="field.placeholder"
:info="field.info"
:required="field.required"
:validate="field.validate"
clear-button
>
</f7-list-input>
</f7-list>验证也可以通过道具..。只是想不出如何在提交时触发它。我假设我需要像示例那样访问框架7的dom?-我试着访问Dom7 -但这是未定义的.我猜是因为vue被利用了?
发布于 2019-06-05 12:02:58
所以..。Dom7可以作为this.Dom7..。checkValidity方法在这方面是可用的。感觉有点像jQuery :)
const $$ = this.Dom7
if (!$$('#ajaxForm')[0].checkValidity()) {
console.log('Check Validity!');
} else {
//ajax request here
return false;
}https://stackoverflow.com/questions/56459358
复制相似问题