vue+iview写个弹框
来源:互联网 发布:野生动植物数量 数据 编辑:程序博客网 时间:2024/06/15 03:02
由于公司项目需要,所以目前捣鼓了vue+iview搭建了一个项目,用的环境都是1.0版本,,
在使用iview弹框中,由于需要先进行弹框中表单的验证,验证通过才调用后台接口,但是呢,,iview弹框中的确定按钮点击一下弹框就消失了,怎么办,要实现效果,各种翻看资料,最终解决办法如下:
<template><!--取消订单弹框和老板批准弹框--> <Modal :visible.sync="show" title="提示" :loading="loading" @on-ok="asyncOK"> <Row> <i-col span="3"></i-col> <i-col span="1" style="color:red;margin-top:7px;font-weight: bold">*</i-col> <i-col span="2" style="margin-top:5px;">授权码</i-col> <i-col span="6"> <input class="ivu-input errorInput" type="number" v-model="code" placeholder="请输入" @blur="codeBlur"> <div class="fade-transition ivu-form-item-error-tip error" style="display:none;position: static">验证码错误</div> </i-col> <i-col span="3" style="margin-left:5px;"> <i-button type="primary" :loading="loadingBtn" @click="toLoading"> <span v-if="!loadingBtn">{{btnText}}</span> <span v-else>{{btnText}}</span> </i-button> </i-col> </Row> </Modal></template><script type="text/javascript">import {orderService} from 'jo'export default {props:["show"],data(){return {loading:true,loadingBtn:false,//点击申请取消按钮后loadingbtnText:'申请取消订单',code:"",//验证码clearTime:"",//定时器countDownIndex:60,//60秒倒计时}},methods:{codeBlur(){if(this.code == ""){$(".errorInput").css("border","1px solid red")$(".error").css("display","block")}else{$(".errorInput").css("border","1px solid #d7dde4")$(".error").css("display","none")}}, toLoading(){ //调用发送验证码接口 // let operName = window.sessionStorage.getItem("userName")// accountService.recommenderGetCode(operName,this.selectDelteOne.recommender,1) this.countDown() }, countDown(){ //倒计时 var that = this; that.loadingBtn = true that.btnText = that.countDownIndex+"秒" that.countDownIndex--; that.clearTime = setInterval(function(){ console.log(that.countDownIndex) if(that.countDownIndex == 0){ that.countDownIndex = 60 that.btnText = "发送" that.loadingBtn = false window.clearTimeout(that.clearTime) return false } that.btnText = that.countDownIndex+"秒" that.countDownIndex--; },1000) // }},asyncOK(){//提交if(this.code == ""){this.show = trueconsole.log('sdasda'+this.show) $(".errorInput").css("border","1px solid red")$(".error").css("display","block")this.loading = falsethis.$nextTick(() => { this.loading = true;});return } this.$nextTick(() => {this.loading = true; }); // let operId = window.sessionStorage.getItem("crmUserId") // let operName = window.sessionStorage.getItem("userName") // if(this.isApply){ // orderService.sendSingleUpdate03(this.data, 3, operName, operId, this.code).then(res => this.updateList(res.message)) // }else{ // orderService.sendSingleUpdate03(this.data, 2, operName, operId, this.code).then(res => this.updateList(res.message)) // }}}}</script>大概思路就是先命名一个变量loading,这里必须为true,然后在点击弹框的提交按钮的时候先把loading设置为false,然后必须加上
this.$nextTick(() => { this.loading = true;});就能实现效果啦,具体实现原理,这坑遇到了,就先记录下来
传送门-->https://github.com/iview/iview/issues/597#issuecomment-292422473
阅读全文
0 0
- vue+iview写个弹框
- 浅谈Vue的iView
- MVC+vue.js+iview
- 创建Vue项目 以及引入Iview
- 创建Vue项目 以及引入Iview
- 深入剖析Vue.js2 iView(一)
- iview
- vue iview组件表格 render函数的使用
- webpack+vue创建简单项目并整合iview
- vueleopard--一个简单的'vue iview webpack'管理系统
- 【VUE】IView.js下拉框数据双向绑定
- 【PC端vue ui框架学习】vue项目如何使用基于vue的UI框架iview
- Vue.js的组件和框架PC与移动 iView elementUI MintUI
- Vue+iview报TypeError: this.$parent.updateGutter is not a function
- vue+iview 当v-for不渲染问题 因为遇到Modal组件
- 如何在 Vue-cli 创建的项目中引入 iView组件UI
- VUE 中 使用 iview Form组件 enter键防止页面刷新
- vue+webpack+iview+less+stylus+ecmascrpit6.0的PC端高手之路(一)新建项目
- win系统 git 的 ssh 秘钥切换到 mac 系统登陆
- 存储过程第二讲:sp模板
- Word2vec使用手册
- 【java基础】05.Java注解Annotation
- Java Head First 第七章 继承与多态
- vue+iview写个弹框
- java.lang.NoClassDefFoundError: org/apache/ibatis/mapping/DatabaseIdProvider
- Java8新特性Optional、接口中的默认方法与静态方法
- 删数游戏(高精度)
- Java IO流学习总结
- Mac 下运行DSO(Direct Sparse Odometry)
- cpu端口读写
- Java实现线程的3种方式
- Spring 注解为空解决方案