vue 解决form表单提交但不跳转页面的问题

来自:网络
时间:2020-05-27
阅读:

vue使用@submit.prevent=""来设置提交时执行的函数,并阻止页面跳转:

 <form id="msgForm" action="" method="post" @submit.prevent="sub">

sub函数写在methods内:

 methods:{
  $.post('http://api.test.ai/visitorinfo/', $('#msgForm').serialize(), function(data){
  console.log(data);
  }) 
 }

以上这篇vue 解决form表单提交但不跳转页面的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

返回顶部
顶部