SpringBoot启动服务器端口8080,但是前端访问却是63342
前端代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
</head>
<body>
<div id="root">
当前时间:{{time}}
<h1>字节跳动</h1>
<form>
账户名:<input type="text" name="username" v-model:value="username" required>
<br>
密码:<input type="password" name="password" v-model:value="password" required>
<button type="submit" @click.self.prevent="login">登录</button>
</form>
<div @click.stop="showInfo">关于本站</div>
</div>
<script>
// 创建vue实例
var vm = new Vue({
data : {
username : '',
password : ''
},
methods : {
login(){
xhr = new XMLHttpRequest()
xhr.open('POST', '/user/login', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
username : this.username,
password : this.password
}))
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert('返回的数据'+xhr.response)
}
}
},
showInfo(){
alert("同学你好")
}
},
computed : {
time(){
localTime = new Date()
year = localTime.getFullYear()
month = localTime.getMonth() + 1
day = localTime.getDate()
return year + '-' + month + '-' + day
}
}
})
vm.$mount('#root')
</script>
</body>
</html>
出现的问题
就算指定了端口号也不对
再次请求