<template>
  <div class="course-tag-wrapper">
    <div class="course-tag-hd">
      <h1 class="tag-title">{{detail.title}}</h1>
    </div>
    <div class="course-tag-bd">
      <div class="course-tag-main">
        <div class="tag-content" v-html="html"></div>
      </div>
    </div>
  </div>
</template>

<script>
import * as api from '@/api/course.js'
export default {
  name: 'CourseTagItem',
  data() {
    return {
      detail: {}
    }
  },
  computed: {
    tagId() {
      return this.$route.params.id
    },
    html() {
      return this.detail.contents
        ? this.detail.contents.replace(/\n/g, '<br/>')
        : ''
    }
  },
  methods: {
    // 获取知识点详情
    getCourseTag() {
      api.getCourseTag(this.tagId).then(response => {
        this.detail = response
      })
    }
  },
  beforeMount() {
    this.getCourseTag()
  }
}
</script>

<style lang="scss" scoped>
.course-tag-wrapper {
  min-height: 100vh;
  background-color: #eee;
  box-sizing: border-box;
}
.course-tag-hd {
  padding: 0.4rem;
  background-color: #fff;
}
.course-tag-bd {
  padding: 0.4rem;
}
.course-tag-main {
  padding: 0.2rem;
  background-color: #fff;
  border-radius: 0.12rem;
}
.tag-title {
  font-size: 0.3rem;
  font-weight: bold;
  color: #222;
  line-height: 0.48rem;
}
.tag-content {
  padding: 20px 0;
  font-size: 13px;
  line-height: 24px;
}
</style>
