<template>
  <div class="main-container">
    <course-item v-for="item in courseList" :data="item" :key="item.course_id"></course-item>
  </div>
</template>

<script>
import * as api from '@/api/course.js'
import CourseItem from '@/components/CourseItem.vue'

export default {
  name: 'Course',
  components: { CourseItem },
  metaInfo: {
    title: '课程学习'
  },
  data() {
    return {
      courseList: []
    }
  },
  methods: {
    getCourseList() {
      this.$toast.loading({
        duration: 0,
        message: '加载中...',
        forbidClick: true
      })
      api
        .getCourseList()
        .then(response => {
          this.courseList = response
        })
        .finally(() => {
          this.$toast.clear()
        })
    }
  },
  beforeMount() {
    this.getCourseList()
  }
}
</script>

<style lang="scss" scoped>
</style>
