Vue v-for中的 input 或 select的值发生改变时触发事件
网络编程 2021-07-04 14:06www.168986.cn编程入门
这篇文章主要介绍了Vue v-for中的 input 或 select的值发生改变时触发事件操作,具有很好的参考价值,希望对大家有所帮助。一起跟随长沙网络推广过来看看吧
oninput 用法
<input type="text" id="myInput" oninput="myFunction()"> <script> function myFunction() { } </script>
oninput 如果需要在Vue中使用则需要写成 v-on:input 还有绑定id的时候这样写:id="'m_num'+index" 注意m_num必须用单引号引起来
<input type="number" :id="'m_num'+index" v-on:input="jsMoney(index)">
jsMoney 方法
jsMoney:function(index){ $("#m_num"+index).val() }
onchange:input 中的文本修改后 在 input 失去焦点后触发
onblur:input 失去焦点后直接触发
oninput:input 文本输入时触发
补充知识:VUE项目中使用this.$forceUpdate();解决页面v-for中修改item属性值后页面v-if不改变的问题
页面展示:
实现效果:点击实现列表内容的展开、折叠。
代码:
<div class="invoice-list" v-for="(item,index) in invoiceData" :key="index"> <div class="images"><img src="../../../../../static/images/invoice_pu.png" v-if="item.invoiceType == '0'"><img src="../../../../../static/images/invoice_zhuan.png" v-else-if="item.invoiceType == '1'"></div> <div class="text"> <h3 v-if="item.invoiceType == '0'">增值税普通发票</h3> <h3 v-else-if="item.invoiceType == '1'">增值税专用发票</h3> <p><span>企业名称:</span>{{item.enterpriseName}}</p> <p><span>税号:</span>{{item.dutyParagraph}}</p> <transition name="fade"> <div class="zhuanInfo" v-if="item.mark == true"> <p><span>注册地址:</span>{{item.address}}</p> <p><span>联系电话:</span>{{item.contactNumber}}</p> <p><span>开户银行:</span>{{item.aountOpeningBank}}</p> <p><span>银行账号:</span>{{item.bankAount }}</p> </div> </transition> <div class="zhuanMark" v-if="item.invoiceType == '1'"> <p class="hideMark"> <img src="../../../../../static/images/arrow_bottom.png" v-if="item.mark == false" @click="clickZhuanMark(index,$event)"> <img src="../../../../../static/images/arrow_.png" v-else @click="clickZhuanMark(index,$event)"> </p> </div> <div class="list-radio"><input type="radio" value="" name="selectContact" @change="getInvoiceId(item.invoiceId)" /></div> </div> </div>
v-for渲染出列表,在执行列表折叠展开时"clickZhuanMark" JS如下:
clickZhuanMark(val,event){ this.invoiceData[val].mark = !this.invoiceData[val].mark; },
可是实际并没有如设想的那样实现效果,之后修改代码:
添加this.$forceUpdate();进行强制渲染,效果实现。搜索资料得出结果:因为数据层次太多,render函数没有自动更新,需手动强制刷新。
以上这篇Vue v-for中的 input 或 select的值发生改变时触发事件操作就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程