Detail.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div>
  3. <ol class="breadcrumb">
  4. <li><a href="/">首页</a></li>
  5. <li><router-link to="/list" class="pull-right">新闻</router-link></li>
  6. <li class="active">{{ detail.title }}</li>
  7. </ol>
  8. <h3><span class="label label-success" v-if="detail.is_recommend">推荐</span> {{ detail.title }}</h3>
  9. <p>创建时间ddd:{{ detail.created_at }}</p>
  10. <div>
  11. {{ detail.content }}
  12. <wv-button type="primary">页面主要操作 Normal</wv-button>
  13. <wv-button type="default">页面次要操作 Normal</wv-button>
  14. <wv-button type="warn">警告类操作 Normal</wv-button>
  15. </div>
  16. </div>
  17. </template>
  18. <style>
  19. .breadcrumb{
  20. padding: 8px 0;
  21. }
  22. </style>
  23. <script>
  24. import { mapState, mapActions } from 'vuex';
  25. export default({
  26. computed: mapState({
  27. detail: state => state.news.detail
  28. }),
  29. created() {
  30. // 获取路由参数id
  31. // js 中用 this.$route 获取当前路由,用 this.$router 获路由对象,全部路由信息
  32. // 在模板中用 $router 和 $router 直接调用
  33. var id = this.$route.params.id;
  34. this.getNewsDetail(id);
  35. },
  36. methods: {
  37. ...mapActions([
  38. 'getNewsDetail'
  39. ])
  40. }
  41. });
  42. </script>