uniapp 手动调用form表单submit事件

背景:

UI把提交的按钮弄成了图片,之前的button不能用了。

<button form-type="submit">搜索</button>

实现:

html:

通过 this.$refs.fd 获取到form的vue对象。手动调用里面的_onSubmit()方法。

复制代码
methods: {
		search(){//图片点击事件
			console.log(this.$refs.fd);
			this.$refs.fd._onSubmit();//手动调用formvue对象的_onSubmit()方法
			// console.log(this.$refs.targetBtn);
		},
		formSubmit(e) {  //原来的form submit事件 不要动,留着
			console.log(e) // 获取原生的 input 事件对
			this.list =[];
			this.formParam =  e.detail.value;
			this.to_Ajax({ ...this.param, ...this.formParam,...this.model});//合并三个参数对象并传递
		},
		formReset(){
			this.param.page = 0;
			this.list = [];
			this.to_Ajax({ ...this.param,...this.model});
			},//合并三个参数对象并传递
		reset(){
			console.log(this.$refs.fd);
			this.$refs.fd._onReset()
			// console.log(this.$refs.targetBtn);
		},
相关推荐
skiyee1 小时前
🔥 oiyo & unibest = 又新又好的 uniapp 模板
前端·uni-app
结网的兔子2 天前
【前端开发】Web端迁移至 uni-app 及鸿蒙扩展方案对比
前端·uni-app·harmonyos
2501_915909062 天前
iOS 应用反调试技详解术 检测调试器的原理与防护实践
android·ios·小程序·https·uni-app·iphone·webview
AI多Agent协作实战派2 天前
AI多Agent协作系统实战(二十八):顶栏统一战争——从1个页面异常到31个页面全量对齐
数据库·人工智能·uni-app
00后程序员张2 天前
iOS加固技术路线全面解析:Bitcode模式、源码模式与汇编模式对比及爱加密优势
android·汇编·ios·小程序·uni-app·cocoa·iphone
2501_916008893 天前
iOS IPA文件反编译与打包操作方法,拆包分析防护和加固打包
android·macos·ios·小程序·uni-app·cocoa·iphone
name好难取诶3 天前
通过对云基座和离线基座的对比,帮助开发者理解如何在不同场景下选择合适的打包方案。 什么是“基座” 在 UniApp 中,基座(也称“ ...
开发语言·uni-app·php
2501_915921433 天前
iOS手游安全反外挂解决方案:基于Xcode的加固混淆特色详解
android·安全·ios·小程序·uni-app·iphone·xcode
2501_916007473 天前
iOS App分发教程 App Store、TestFlight 与 Ad Hoc 的配置与上传方法
android·ios·小程序·https·uni-app·iphone·webview
qq_316837753 天前
uniapp 打包APP 使用 Galacean Effects 的特效
uni-app