forked from Tencent/APIJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
122 lines (108 loc) · 2.46 KB
/
App.vue
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
<div id="app">
<img src="./assets/logo.png">
<div class="#show">动态内容: {{ this.Moment.content}}</div>
<div class="#show">发布者: {{ this.User.name }}</div>
<button @click="ok()" >{{ this.msg }}</button>
<ul>
<div v-for="item in commentList">
{{ item.User.name + ': ' + item.Comment.content }}
</div>
</ul>
</div>
</template>
<script>
import axios from 'axios'
// axios.defaults.withCredentials = true
let url_base = "http://apijson.cn:8080"
let url_get = url_base + "/get"
let url_head = url_base + "/head"
let url_post_get = url_base + "/post_get"
let url_post_head = url_base + "/post_head"
let url_post = url_base + "/post"
let url_put = url_base + "/put"
let url_delete = url_base + "/delete"
let model = {
msg: 'APIJSON',
Moment: {
content: 'content'
},
User: {
name: 'name'
},
commentList: {
}
}
export default {
name: 'app',
data () {
return model
},
methods: {
ok() {
// 刷新界面
function refresh(data) {
data = data || {}
model.Moment = data.Moment || {}
model.User = data.User || {}
model.commentList = data['[]'] || []
console.log('refresh model = \n' + JSON.stringify(model))
}
axios.post(url_get,
{
'Moment': {
'userId': 93793
},
'User': {
'id': 93793
},
'[]': {
'count': 5,
'Comment': {
'momentId@': 'Moment/id'
},
'User': {
'id@': '/Comment/userId'
}
}
})
.then(function (response) {
refresh(response.data)
})
.catch(function (error) {
console.log(error);
})
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
#show {
height: 100px;
width: 1000px;
background-color: #000000;
text-decoration-color: #ffffff;
}
</style>