-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (48 loc) · 1.09 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<title>
word cloud
</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<form id="post_form" enctype="multipart/form-data" method="post" action="http://localhost:5000/wordcloud">
<input id="file_input" type="file" name="file">
<input type="submit" name="提交">
</form>
<div id="app">
<button v-on:click="submit">vue submit</button>
<img v-bind:src="image_data">
</div>
</body>
<style>
input {
display: block;
}
</style>
<script>
// 实现表单的ajax请求
var app = new Vue({
el: "#app",
data: {
image_data: ""
},
methods: {
submit: function () {
var that = this
var formData = new FormData()
formData.append("file", document.getElementById("file_input").files[0])
var request = new XMLHttpRequest();
request.open("POST", "http://localhost:5000/wordcloud")
request.send(formData)
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
that.$data.image_data = request.response
}
}
}
}
});
</script>
</html>