List.vue 905 B

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <div class="panel panel-default">
  3. <div class="panel-heading">新闻列表</div>
  4. <ul class="list-group">
  5. <li class="list-group-item"
  6. v-for="row in lists">
  7. <router-link :to="{path:'/detail/' + row.id}">
  8. <span class="label label-success" v-if="row.is_recommend">推荐</span>
  9. {{ row.title }}
  10. </router-link>
  11. <span class="pull-right">{{ row.created }}</span>
  12. </li>
  13. </ul>
  14. </div>
  15. </template>
  16. <script>
  17. import { mapState, mapActions } from 'vuex';
  18. export default({
  19. computed: mapState({
  20. lists: state => state.news.lists
  21. }),
  22. created() {
  23. this.getNewsLists();
  24. },
  25. methods: {
  26. ...mapActions([
  27. 'getNewsLists'
  28. ])
  29. }
  30. });
  31. </script>