解决关于 vue项目中 点击提交按钮路由多了个问号

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/qq_42968609/article/details/88367813

问题描述:

在vue项目开发过程中,新建参数表以表单形式提交,发现页面重新刷新,路径中多了问号

http://localhost:8100/#/
改变为
http://localhost:8100/?#/

导致路由跳转出现问题。

原因:

这里是 form 表单,点击了button 按钮,触发了他的默认事件,就是触发了提交这个行为。

解决方案

使用@click.prevent 阻止默认事件

<a-button type="primary" @click.prevent="handleSubmit" :loading="submitLoading">
	确认
</a-button>

猜你喜欢

转载自blog.csdn.net/qq_42968609/article/details/88367813