问题描述:
在vue项目开发过程中,新建参数表以表单形式提交,发现页面重新刷新,路径中多了问号
http://localhost:8100/#/
改变为
http://localhost:8100/?#/
导致路由跳转出现问题。
原因:
这里是 form 表单,点击了button 按钮,触发了他的默认事件,就是触发了提交这个行为。
解决方案
使用@click.prevent 阻止默认事件
<a-button type="primary" @click.prevent="handleSubmit" :loading="submitLoading">
确认
</a-button>
方案二
el-from 加上 @submit.native.prevent