Summary of problems encountered in Vue scaffolding project

When the hash route jumps in vue, the url path is added with a question mark

http://localhost:8081/?#/BroadbandPay

reason

You use the form form. The bubbling or default event should be prevented during onSubmit.

For example, the following code is an error case, the form is submitted using a button

<form>
  <input v-model="user.account" type="text" placeholder="请输入用户名" required>
  <input v-model="user.password" type="password" placeholder="请输入用户密码" required>
  <button  @click="axios_StudentLogin">登录</button >
</form>

Solution 1

lift the button out

<form>
  <input v-model="user.account" type="text" placeholder="请输入用户名" required>
  <input v-model="user.password" type="password" placeholder="请输入用户密码" required>
</form>
<button  @click="axios_StudentLogin">登录</button >

Solution 2

Use click.prevent to prevent the default event, just fine.

<form>
  <input v-model="user.account" type="text" placeholder="请输入用户名" required>
  <input v-model="user.password" type="password" placeholder="请输入用户密码" required>
  <button  @click.prevent="axios_StudentLogin">登录</button >
</form>                    

Guess you like

Origin blog.csdn.net/qq_39123467/article/details/129872885