12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <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 {
- articleInfo: {},
- imageList: [],
- }
- },
- computed: {
- html() {
- const html = this.articleInfo.articleContent
- if (html) {
- return html.replace(/href=/gi, '')
- }
- return ''
- },
- },
- mounted() {
- this.initData()
- },
- methods: {
- initData() {
- const articleInfo = localStorage.getItem('articleInfo')
- if (articleInfo) {
- this.articleInfo = JSON.parse(articleInfo)
- this.fetchArticleDetail()
- }
- },
- async fetchArticleDetail() {
- try {
- const res = await this.$http.api.getArticleDetail({
- articleId: this.articleInfo.articleId,
- })
- this.articleInfo = { ...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 {
- @include ellipsis(2);
- 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) {
- }
- </style>
|