File tree Expand file tree Collapse file tree 7 files changed +87
-5
lines changed Expand file tree Collapse file tree 7 files changed +87
-5
lines changed Original file line number Diff line number Diff line change 13
13
"lint" : " eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
14
14
},
15
15
"dependencies" : {
16
+ "axios" : " ^0.15.3" ,
16
17
"element-ui" : " ^1.1.2" ,
18
+ "lodash" : " ^4.17.4" ,
17
19
"normalize.css" : " ^5.0.0" ,
18
20
"vue" : " ^2.1.0" ,
19
21
"vue-router" : " ^2.1.1"
Original file line number Diff line number Diff line change 2
2
<div id =" container" >
3
3
<TopBar ></TopBar >
4
4
<transition >
5
- <router-view ></router-view >
5
+
6
+ <el-row type =" flex" class =" row-bg" justify =" center" >
7
+ <el-col :span =" 20" ><router-view ></router-view ></el-col >
8
+ <!-- <el-col :span="6"><router-view></router-view></div></el-col>-->
9
+ </el-row >
10
+
11
+ <!-- <el-row>
12
+ <el-col :span="23"><router-view></router-view></div></el-col>
13
+ </el-row>-->
6
14
</transition >
7
15
</div >
8
16
</template >
Original file line number Diff line number Diff line change 3
3
<div class =" logo" >
4
4
<router-link to =" /" >
5
5
<!-- <img src="../../assets/images/logo.svg" />-->
6
+ <p >星辰</p>
6
7
</router-link>
7
8
</div>
8
9
<el-submenu index =" 1" >
9
10
<template slot="title"><i class =" el-icon-menu" ></i >导航一</template >
10
- <el-menu-item index =" 1-1" ><router-link to =" /page1 " class =" nav-link" >二级导航一 </router-link></el-menu-item>
11
+ <el-menu-item index =" 1-1" ><router-link to =" /question " class =" nav-link" >Ajax Demo </router-link></el-menu-item>
11
12
<el-menu-item index="1-2"><router-link to =" /page2" class =" nav-link" >二级导航二</router-link></el-menu-item>
12
13
</el-submenu>
13
14
<el-menu-item index =" 2" ><router-link to =" /page3" class =" nav-link" ><i class =" el-icon-message" ></i>导航二</router-link></el-menu-item>
Original file line number Diff line number Diff line change 148
148
height : 60px ;
149
149
text-align : center ;
150
150
background-color : #20202A ;
151
- img {
152
- margin-top : 12px ;
151
+ p {
152
+ margin : 0 ;
153
+ padding-top : 20px ;
154
+ font-size : 20px ;
155
+ color : white ;
153
156
}
154
157
}
155
158
.nav-link {
Original file line number Diff line number Diff line change 1
1
<template lang="html">
2
2
<div class =" home" >
3
- <h1 >这是首页</h1>
3
+ <!-- < h1>这是首页</h1> -- >
4
4
<!-- <img src="../assets/images/home.jpg" width="100%" />-->
5
5
<p >首页</p>
6
6
</div>
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <el-form ref =" form" :model =" yesno" label-width =" 80px" >
4
+ <el-form-item label =" 问题:" >
5
+ <el-input v-model =" yesno.question" ></el-input >
6
+ <p v-bind:style =" { color: yesno.answerColor }" >{{ yesno.answer }}</p >
7
+ <img :src =" yesno.img" >
8
+ </el-form-item >
9
+ </el-form >
10
+ </div >
11
+ </template >
12
+
13
+ <script >
14
+ import _ from ' lodash'
15
+ import axios from ' axios'
16
+
17
+ export default {
18
+ props: [' msg' ],
19
+ data : function () {
20
+ return {
21
+ yesno: {
22
+ question: ' ' ,
23
+ answer: ' 提个对错问题?' ,
24
+ answerColor: null ,
25
+ img: ' '
26
+ }
27
+ }
28
+ },
29
+ watch: {
30
+ ' yesno.question ' : function (newQuestion ) {
31
+ this .yesno .answer = ' 正在等你停止输入'
32
+ this .yesno .img = ' '
33
+ this .getAnswer ()
34
+ }
35
+ },
36
+ methods: {
37
+ getAnswer: _ .debounce (
38
+ function () {
39
+ let vm = this .yesno
40
+ if (vm .question .indexOf (' ?' ) === - 1 ) {
41
+ vm .answer = ' 需要一个英文问号结尾. ;-)'
42
+ return
43
+ }
44
+ vm .answer = ' 正在想...'
45
+ axios .get (' https://yesno.wtf/api/' )
46
+ .then (function (response ) {
47
+ vm .answer = _ .capitalize (response .data .answer )
48
+ vm .img = _ .capitalize (response .data .image )
49
+ vm .answerColor = ' green'
50
+ })
51
+ .catch (function (error ) {
52
+ vm .answer = ' Error! Could not reach the API. ' + error
53
+ vm .answerColor = ' red'
54
+ })
55
+ },
56
+ // 这是我们为用户停止输入等待的毫秒数
57
+ 500
58
+ )
59
+ }
60
+ }
61
+ </script >
62
+ <style >
63
+
64
+ </style >
Original file line number Diff line number Diff line change @@ -2,5 +2,9 @@ export default [
2
2
{
3
3
path : '/' ,
4
4
component : resolve => require ( [ './pages/home/home.vue' ] , resolve )
5
+ } ,
6
+ {
7
+ path : '/question' ,
8
+ component : resolve => require ( [ './pages/question' ] , resolve )
5
9
}
6
10
]
You can’t perform that action at this time.
0 commit comments