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

vue使用@submit.prevent=""来设置提交时执行的函数,并阻止页面跳转: <form id="msgForm" action="" method="post" @submit.prevent="sub"> sub函数写在methods内: methods:{ $....

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);
  }) 
 }

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
粪斗
粪斗

185 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章