-
Notifications
You must be signed in to change notification settings - Fork 212
/
Articles.vue
101 lines (100 loc) · 2.27 KB
/
Articles.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
<template>
<section class="articles">
<router-link :to="{name:'editor'}"
tag="button">新增文章
</router-link>
<table>
<tbody>
<tr>
<th>标题</th>
<th>日期</th>
<th>选项</th>
</tr>
<tr v-for="(article,index) in articles">
<router-link :to="{name:'article',query:{id:article._id}}"
tag="td">
{{article.title}}
</router-link>
<td>
{{article.date | toDate}}
</td>
<td>
<router-link class="fa fa-pencil-square-o"
:to="{name:'editor',query:{id:article._id}}"
tag="i">
</router-link>
<i class="fa fa-trash"
@click="deleteArticle(article._id)">
</i>
</td>
</tr>
</tbody>
</table>
</section>
</template>
<script>
import {mapState, mapActions} from 'vuex'
export default{
created(){
this.getArticles()
},
computed: mapState(['articles']),
methods: mapActions(['getArticles', 'deleteArticle'])
}
</script>
<style lang="sass" rel="stylesheet/scss" scoped>
@import "../../style/mixins.scss";
section.articles {
@include rightSide();
button {
@include center();
position: relative;
width: 200px;
height: 60px;
margin: 30px 0;
font-size: 20px;
}
table {
position: absolute;
@include center();
top: 150px;
width: 60%;
tr {
height: 50px;
th {
font-weight: normal;
cursor: pointer;
&:first-of-type {
width: 40%;
min-width: 40px;
}
&:nth-of-type(2) {
width: 30%;
min-width: 200px;
}
&:last-of-type {
width: 30%;
min-width: 100px;
cursor: default;
}
}
td:first-of-type {
color: $green1;
cursor: pointer;
}
td:nth-of-type(2), td:nth-of-type(3) {
text-align: center;
}
td i {
color: $green2;
cursor: pointer;
}
td i:after {
display: inline-block;
width: 10px;
content: '';
}
}
}
}
</style>