123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <template>
- <div class="page">
- <div class="page-top">
- <div class="title" v-text="articleInfo.articleTitle"></div>
- <div class="date">{{ articleInfo.createTime | dateFormat }}</div>
- </div>
- <div class="page-content" v-html="html"></div>
- </div>
- </template>
- <script>
- export default {
- layout: 'app',
- data() {
- return {
- articleId: '',
- articleInfo: {},
- imageList: [],
- }
- },
- computed: {
- html() {
- const html = this.articleInfo.articleContent
- if (html) {
- return html.replace(/href=/gi, '')
- }
- return ''
- },
- },
- mounted() {
- this.initData()
- },
- methods: {
- initData() {
- this.articleId = parseInt(this.$route.query.id)
- this.fetchArticleDetail()
- },
- async fetchArticleDetail() {
- try {
- const res = await this.$http.api.getArticleDetail({
- articleId: this.articleId,
- })
- this.articleInfo = res.data
- } catch (error) {
- console.log(error)
- }
- },
- },
- }
- </script>
- <style scoped lang="scss">
- /* scss中可以用mixin来扩展 */
- @mixin ellipsis($line: 1) {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: $line;
- -webkit-box-orient: vertical;
- }
- // pc 端
- @media screen and (min-width: 768px) {
- .page {
- width: 1200px;
- margin: 24px auto;
- box-sizing: border-box;
- background: #fff;
- padding: 24px;
- }
- .page-top {
- padding-bottom: 24px;
- border-bottom: 1px solid #d8d8d8;
- .title {
- font-size: 28px;
- color: #101010;
- line-height: 1.6;
- text-align: justify;
- }
- .date {
- font-size: 18px;
- color: #b2b2b2;
- margin-top: 24px;
- }
- }
- .page-content {
- padding-top: 24px;
- color: #404040;
- }
- }
- // 移动 端
- @media screen and (max-width: 768px) {
- .page {
- box-sizing: border-box;
- background: #fff;
- padding: 4vw;
- }
- .page-top {
- .title {
- font-size: 4.2vw;
- color: #101010;
- line-height: 1.6;
- text-align: justify;
- }
- .date {
- font-size: 3.2vw;
- color: #b2b2b2;
- margin-top: 4vw;
- }
- }
- .page-content {
- padding-top: 24px;
- color: #404040;
- }
- }
- </style>
|