-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.html
More file actions
47 lines (44 loc) · 1.38 KB
/
Copy pathchat.html
File metadata and controls
47 lines (44 loc) · 1.38 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Chat</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="root">
<div class="container">
<message v-for="message in messages" :username="message.username" :message="message.message"></message>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://unpkg.com/vue@2.4.2"></script>
<script src="chat.js"></script>
<script>
var vm = new Vue({
el: "#root",
data: {
messages:[],
},
mounted:function(){
this.getMessages();
},
methods:{
getMessages(){
$.ajax({
url:'http://api.codelab.camp/messages',
type:'GET',
dataType:'json',
success:function (results) {
vm.messages = results;
}
});
}
}
});
</script>
</body>
</html>