Detail.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="col-md-9">
  3. <div class="news-detail" v-bind="item">
  4. <h1 >{{item.title}}</h1>
  5. <div class="hot-time">
  6. <span class="text-num">时间:<span >{{item.created | date}}</span></span>
  7. <span class="pull-right text-num" style="font-size: 12px;"><i class="fa fa-eye" style="margin-left: 15px;"></i>{{item.viewCount}}</span>
  8. </div>
  9. <div class="news-detail-content" v-html=item.content>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. // import axios from '~plugins/axios'
  16. export default {
  17. name: 'Detail',
  18. // data () {
  19. // return {
  20. // new: {}
  21. // }
  22. // },
  23. // mounted () {
  24. // this.$http.get(`/api/news/${this.$route.params.id}`)
  25. // .then(response => {
  26. // this.new = response
  27. // })
  28. // },
  29. computed: {
  30. new () {
  31. return this.$store.state.newsData.detailNews.detailNews
  32. },
  33. item () {
  34. if (this.new.data) {
  35. return this.new.data
  36. }
  37. }
  38. },
  39. filters: {
  40. date: function (input) {
  41. const d = new Date(input)
  42. const year = d.getFullYear()
  43. const monthTemp = d.getMonth() + 1
  44. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  45. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours() + ' '
  46. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  47. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  48. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped>
  54. .col-md-9{
  55. padding-left: 0;
  56. float: right;
  57. margin-top: 10px;
  58. }
  59. @media (min-width: 992px) {
  60. .col-md-9 {
  61. width: 75%;
  62. }
  63. }
  64. .news-detail {
  65. width: 100%;
  66. margin: 0 auto;
  67. }
  68. .news-detail h1 {
  69. font-size: 24px;
  70. line-height: 40px;
  71. margin: 0;
  72. }
  73. .news-detail .hot-time {
  74. margin-bottom: 20px;
  75. }
  76. .hot-time span {
  77. font-size: 14px;
  78. color: #999;
  79. }
  80. .news-detail-content {
  81. width: 100%;
  82. margin: 0 auto;
  83. font-size: 14px;
  84. border-top: #e8e8e8 1px solid;
  85. padding-top: 20px;
  86. line-height: 28px;
  87. color: #666;
  88. }
  89. </style>