Blogger Information
Blog 91
fans 0
comment 0
visits 203537
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
layui框架【坑】,form提交了两次,问题原因
何澤小生的博客
Original
1673 people have browsed it

刚刚在写ajax的时候,发现表单提交了两次,代码如下:

  1. <script type='text/javascript' src="./layui/layui.all.js"></script>
  2. <script type='text/javascript' src="./layui/layui.js"></script>
  3. //表单提交
  4. layui.use('form', function(){
  5. var form = layui.form;
  6. form.on('submit(SendCode)', function () {
  7. alert('form');
  8. return false;
  9. });
  10. });

原来,layui.js自动所有包含了modules模块,我本地额外的引入了 /layui/lay/modules/form.js

其中 layui.js 引入一次,layui.all.js 引入一次导致提交表单中操作处理两次………………,,真的是个深坑,记得避开

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
z老师 2020-09-14 10:42:56
感谢分享,赞一个!
1 floor
Author's latest blog post