2022-10-31 08:59:21 +00:00
|
|
|
|
<!--
|
|
|
|
|
* @Author: Kane
|
|
|
|
|
* @Date: 2022-10-31 13:11:55
|
|
|
|
|
* @LastEditors: Kane
|
2022-10-31 15:08:51 +00:00
|
|
|
|
* @LastEditTime: 2022-10-31 22:58:03
|
2022-10-31 08:59:21 +00:00
|
|
|
|
* @FilePath: \car_dealer\vue\axios.html
|
|
|
|
|
* @Description:
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
|
|
|
|
-->
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
|
<title>axios</title>
|
|
|
|
|
<link rel="stylesheet" href="../css/root.css" />
|
|
|
|
|
<link rel="stylesheet" href="../css/normalize.css" />
|
|
|
|
|
<link rel="stylesheet" href="../css/kane.css" />
|
|
|
|
|
<link rel="stylesheet" href="../css/axios/axios.css" />
|
2022-10-31 15:08:51 +00:00
|
|
|
|
<!-- <script src="https://unpkg.com/axios@1.1.3/dist/axios.min.js"></script> -->
|
|
|
|
|
<script src="../js/axios/1.1.3/axios.js"></script>
|
2022-10-31 08:59:21 +00:00
|
|
|
|
<script src="../js/vue/vue.global.js"></script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<div id="app">
|
|
|
|
|
<div class="main_plane">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="file_name"
|
|
|
|
|
id="file_name"
|
|
|
|
|
readonly
|
|
|
|
|
onclick="selectFile()"
|
|
|
|
|
/>
|
|
|
|
|
<button type="button" @click="onUploadFile()">上传</button>
|
|
|
|
|
<input
|
|
|
|
|
type="file"
|
|
|
|
|
name="uploadFile"
|
|
|
|
|
id="fileupload"
|
|
|
|
|
onchange="onFileuploadChange()"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
<script>
|
|
|
|
|
const UPLOAD_FILE_URL =
|
|
|
|
|
"http://localhost:8080/cardealer/upload/upload_file.do";
|
|
|
|
|
const IMPORT_CARDEALER_URL =
|
|
|
|
|
"http://localhost:8080/cardealer/data/import/importcardealer.do";
|
|
|
|
|
|
|
|
|
|
function selectFile() {
|
|
|
|
|
const upload_file = document.getElementById("fileupload");
|
|
|
|
|
const file_name = document.getElementById("file_name");
|
|
|
|
|
|
|
|
|
|
upload_file.click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onFileuploadChange() {
|
|
|
|
|
const upload_file = document.getElementById("fileupload");
|
|
|
|
|
const file_name = document.getElementById("file_name");
|
|
|
|
|
|
|
|
|
|
file_name.value = upload_file.value;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<script>
|
|
|
|
|
const app = {
|
|
|
|
|
data() {
|
2022-10-31 10:01:26 +00:00
|
|
|
|
return {
|
|
|
|
|
test: "测试this!",
|
|
|
|
|
};
|
2022-10-31 08:59:21 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
onUploadFile: function () {
|
|
|
|
|
let param = {
|
|
|
|
|
file_path: "file path",
|
|
|
|
|
table_name: "车商表",
|
|
|
|
|
};
|
2022-10-31 10:01:26 +00:00
|
|
|
|
|
2022-10-31 08:59:21 +00:00
|
|
|
|
axios
|
|
|
|
|
.post(IMPORT_CARDEALER_URL, param)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
console.log(response);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2022-10-31 15:08:51 +00:00
|
|
|
|
//先检查response,看看是否因为状态码不是200
|
|
|
|
|
if (error.response) {
|
|
|
|
|
console.log(error.response.data);
|
|
|
|
|
console.log(error.response.status);
|
|
|
|
|
}
|
|
|
|
|
//没有收到响应,就检查request
|
|
|
|
|
else if (error.request) {
|
|
|
|
|
console.log(error.request);
|
|
|
|
|
}
|
|
|
|
|
//如果request也为undefined,说明是引擎抛出了异常
|
|
|
|
|
else {
|
|
|
|
|
console.log(error.message);
|
|
|
|
|
}
|
2022-10-31 08:59:21 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const vm = Vue.createApp(app);
|
|
|
|
|
|
|
|
|
|
vm.mount("#app");
|
|
|
|
|
</script>
|
|
|
|
|
</html>
|