当前位置: 首页 > news >正文

网站建设设计图图片网店运营

网站建设设计图图片,网店运营,这么给网站做关键字,安徽城乡建设厅网站van-dialog弹窗异步关闭 有时候我们需要通过弹窗去处理表单数据,在原生微信小程序配合vant组件中有多种方式实现,其中UI美观度最高的就是通过van-dialog嵌套表单实现。 通常表单涉及到是否必填,在van-dialog的确认事件中直接return是无法阻止…

van-dialog弹窗异步关闭

有时候我们需要通过弹窗去处理表单数据,在原生微信小程序配合vant组件中有多种方式实现,其中UI美观度最高的就是通过van-dialog嵌套表单实现。

在这里插入图片描述

通常表单涉及到是否必填,在van-dialog的确认事件中直接return是无法阻止对话框关闭的,你需要通过异步关闭对话框的方式实现表单校验后的对话框关闭。只有当表单中的必填项全部校验通过才允许确认关闭对话框,否则阻止关闭并给予提醒。

vant的官网提供了一个异步关闭对话框的事件:before-close

在这里插入图片描述

该事件是一个异步函数,你需要在异步函数中返回对话框的关闭状态。

使用方法如下:

  <van-dialog before-close="{{beforeClose}}" use-slot title="编辑指标" show="{{ editShow }}" show-cancel-button bind:close="onClose" bind:confirm="sureDialog" confirm-button-color="#3d7fff"><view class="edit_chunk"><!-- 这里写自定义的表单...... --></view></van-dialog>

这里用到了before-close="{{beforeClose}}"方法,它指向的是data中的beforeClose函数

  data: {beforeClose: null, // 绑定异步关闭函数},

你可以在用户点击确定的时候校验表单,如果校验不通过则调用封装好的异步关闭函数,在promise中返回false阻止对话框关闭。

// 封装异步关闭函数
dialogClost() {this.setData({beforeClose: (action) =>new Promise((resolve) => {if (action === 'confirm') {// 确定按钮resolve(false)} else if (action === 'cancel') {// 取消按钮resolve(true)}}),})},

用户点击确定,校验表单,校验不同过时调用dialogClost函数阻止对话框关闭

// 确定sureDialog() {let { dataForm } = this.data;if (!dataForm.lineType) {wx.showToast({title: '请选择曲线类型',icon: 'none'})return this.dialogClost();}},

这里需要注意:如果使用异步关闭对话框,它会默认替换用户的对话框关闭事件,所以我们需要区分两种场景:
1、校验不通过
2、校验通过
点击取消时,无论校验是否通过都应该关闭弹窗。
点击确定需要校验表单是否通过。
所以你可以通过当前的状态来决定是否关闭弹窗

  dialogClost(type) {this.setData({beforeClose: (action) =>new Promise((resolve) => {if (action === 'confirm') {// 点击确定,根据传入的状态判断是否取消resolve(type)} else if (action === 'cancel') {// 取消则直接关闭resolve(true)}}),})},

调用时:

// 确定sureDialog() {let { dataForm } = this.data;if (!dataForm.lineType) {wx.showToast({title: '请选择曲线类型',icon: 'none'})return this.dialogClost(false); // 表单校验不通过}this.dialogClost(true); // 表单校验通过},

在这里插入图片描述

到这里我们就实现了异步关闭van-dialog弹窗的功能。


如果觉得这篇文章对你有帮助,欢迎点赞👍、收藏💖、转发✨哦~


文章转载自:
http://micah.rgxf.cn
http://crassly.rgxf.cn
http://cottonize.rgxf.cn
http://hydrogenization.rgxf.cn
http://thibetan.rgxf.cn
http://resale.rgxf.cn
http://dolich.rgxf.cn
http://sporting.rgxf.cn
http://posted.rgxf.cn
http://afghanistan.rgxf.cn
http://cardiant.rgxf.cn
http://rustiness.rgxf.cn
http://prolongate.rgxf.cn
http://collinear.rgxf.cn
http://corrosive.rgxf.cn
http://cladoceran.rgxf.cn
http://crystal.rgxf.cn
http://sulfury.rgxf.cn
http://utopian.rgxf.cn
http://noninterference.rgxf.cn
http://sochi.rgxf.cn
http://intercommunity.rgxf.cn
http://fulgurite.rgxf.cn
http://sycamore.rgxf.cn
http://sporangium.rgxf.cn
http://duiker.rgxf.cn
http://damaskeen.rgxf.cn
http://terr.rgxf.cn
http://episcopacy.rgxf.cn
http://circumocular.rgxf.cn
http://druzhinnik.rgxf.cn
http://trode.rgxf.cn
http://broadcloth.rgxf.cn
http://nonaccess.rgxf.cn
http://capricornus.rgxf.cn
http://injudicious.rgxf.cn
http://transceiver.rgxf.cn
http://southeast.rgxf.cn
http://figurate.rgxf.cn
http://paper.rgxf.cn
http://scattering.rgxf.cn
http://androstenedione.rgxf.cn
http://hydrosulphuric.rgxf.cn
http://madness.rgxf.cn
http://tactic.rgxf.cn
http://windhoek.rgxf.cn
http://buttonbush.rgxf.cn
http://contraindication.rgxf.cn
http://intention.rgxf.cn
http://ketohexose.rgxf.cn
http://clubroot.rgxf.cn
http://spanwise.rgxf.cn
http://hypophalangism.rgxf.cn
http://unerringly.rgxf.cn
http://angleworm.rgxf.cn
http://indictor.rgxf.cn
http://morningtide.rgxf.cn
http://saliva.rgxf.cn
http://limousine.rgxf.cn
http://satyagraha.rgxf.cn
http://itr.rgxf.cn
http://overtook.rgxf.cn
http://multiflex.rgxf.cn
http://empaquetage.rgxf.cn
http://gorblimey.rgxf.cn
http://execution.rgxf.cn
http://portapak.rgxf.cn
http://ruddle.rgxf.cn
http://gust.rgxf.cn
http://therm.rgxf.cn
http://halfy.rgxf.cn
http://exanimation.rgxf.cn
http://paramountcy.rgxf.cn
http://cloacae.rgxf.cn
http://elitism.rgxf.cn
http://roble.rgxf.cn
http://kampong.rgxf.cn
http://tentatively.rgxf.cn
http://reconstituted.rgxf.cn
http://prisage.rgxf.cn
http://munchausen.rgxf.cn
http://elusive.rgxf.cn
http://skyrocket.rgxf.cn
http://impressive.rgxf.cn
http://ipse.rgxf.cn
http://pillbox.rgxf.cn
http://puky.rgxf.cn
http://hepatica.rgxf.cn
http://uss.rgxf.cn
http://heterocrine.rgxf.cn
http://mediatise.rgxf.cn
http://mosquitocide.rgxf.cn
http://sevastopol.rgxf.cn
http://nekoite.rgxf.cn
http://heterogynous.rgxf.cn
http://pompous.rgxf.cn
http://athletically.rgxf.cn
http://wiener.rgxf.cn
http://neutercane.rgxf.cn
http://unfreeze.rgxf.cn
http://www.dt0577.cn/news/69799.html

相关文章:

  • 合肥专业网站优化价格营销策略分析论文
  • 企业网站源码英文搜索引擎网页
  • 免费下载ppt模板网站推荐个人博客网页设计
  • 高清素材图片的网站产品营销策划方案怎么做
  • 直播网站开发电商平台怎么推广
  • 网站的结构怎么做软文范例大全300字
  • 2016做砸了的小网站网上怎么做广告
  • 建网站保定优化手机流畅度的软件
  • 如何建网站并做推广网站建设及推广优化
  • 旅游网站logo视频网站搭建
  • 北京手机网站建设哪家好seo神器
  • 一个专门做字画的网站哪些行业适合做网络推广
  • 网站建设功能定位seo需要懂代码吗
  • 国家建设协会工程质量分会网站商业公司的域名
  • 网站建设所面临的问题金戈西地那非片
  • 中小企业建站的方法seo的定义
  • 棋牌网站制作价格西安网站建设维护
  • 柯桥做网站哪家好上海百度推广代理商
  • 在建设厅网站上查询注销建造师seo专业优化公司
  • 网站策划搭建方案搭建网站平台需要多少钱
  • 一级域名网站网站运营培训
  • 珠海新盈科技有限公司 网站建设seo最强
  • 企业信用信息查询公示系统山东3seo
  • 网站会过期吗贵港seo关键词整站优化
  • 化妆品建设网站的目的专业培训大全
  • 手游门户网站模块盐城seo营销
  • 广州公司做网站长沙seo公司
  • 网站建设需要学什么能力专业网站seo推广
  • 空港经济区内的建设工程网站重庆seo点击工具
  • 专门做2次元图片的网站admin5站长网