• 在线教育项目-day11【前端显示】


    1.新建utils文件夹,新建request.js

     2.下载axios

    3.书写request.js

    import axios from 'axios'
    // 创建axios实例
    const service = axios.create({
      baseURL: 'http://localhost:9001', // api的base_url
      timeout: 20000 // 请求超时时间
    })
    export default service

    4.新建api文件夹,创建index.js

    import request from '@/utils/request'
    export default{
        index(){
            return request({
                url: '/eduservice/indexfont/index',
                method:'get'
            })
            
        }
    }

    5.书写前端页面方法

    <script>
    import index from '@/api/index'
    export default {
      data(){
        return {
          courseList: [],
          teacherList: []

        }
      },
      created(){
        this.getHotCourseAndTeacher()




      },
      methods:{
        getHotCourseAndTeacher(){
          index.index()
            .then(response=>{
              this.courseList=response.data.data.CourseList
              this.teacherList=response.data.data.TeacherList
            })
        }

      }
      
    }
    </script>

    6.改写前端页面

    <template>
      
      <div>
        <div id="wrap" style="background: #040B1B; ">
                <img src="~/assets/photo/banner/1525939573202.jpg" />
        </div> 
         <div id="aCoursesList">
          <!-- 网校课程 开始 -->
          <div>
            <section class="container">
              <header class="comm-title">
                <h2 class="tac">
                  <span class="c-333">热门课程</span>
                </h2>
              </header>
              <div>
                <article class="comm-course-list">
                  <ul class="of" id="bna">
                    <li v-for="course in courseList" :key="course.id">
                      <div class="cc-l-wrap">
                        <section class="course-img">
                          <img
                            :src="course.cover"
                            class="img-responsive"
                            :alt="course.title"
                          >
                          <div class="cc-mask">
                            <a href="#" title="开始学习" class="comm-btn c-btn-1">开始学习</a>
                          </div>
                        </section>
                        <h3 class="hLh30 txtOf mt10">
                          <a href="#" title="听力口语" class="course-title fsize18 c-333">{{course.title}}</a>
                        </h3>
                        <section class="mt10 hLh20 of">
                          <span class="fr jgTag bg-green" v-if="Number(course.price)===0">
                            <i class="c-fff fsize12 f-fA">免费</i>
                          </span>
                          <span class="fl jgAttr c-ccc f-fA">
                            <i class="c-999 f-fA">9634人学习</i>
                            |
                            <i class="c-999 f-fA">9634评论</i>
                          </span>
                        </section>
                      </div>
                    </li>
                    
                  </ul>
                  <div class="clear"></div>
                </article>
                <section class="tac pt20">
                  <a href="#" title="全部课程" class="comm-btn c-btn-2">全部课程</a>
                </section>
              </div>
            </section>
          </div>
          <!-- /网校课程 结束 -->
          <!-- 网校名师 开始 -->
          <div>
            <section class="container">
              <header class="comm-title">
                <h2 class="tac">
                  <span class="c-333">名师大咖</span>
                </h2>
              </header>
              <div>
                <article class="i-teacher-list">
                  <ul class="of">
                    <li v-for="teacher in teacherList" :key=teacher.id >
                      <section class="i-teach-wrap">
                        <div class="i-teach-pic">
                          <a href="/teacher/1" title="teacher.name">
                            <img :alt="teacher.name" :src="teacher.avatar" width="500" height="100">
                          </a>
                        </div>
                        <div class="mt10 hLh30 txtOf tac">
                          <a href="/teacher/1" title="teacher.name" class="fsize18 c-666">{{teacher.name}}</a>
                        </div>
                        <div class="hLh30 txtOf tac">
                          <span class="fsize14 c-999">{{teacher.career}}</span>
                        </div>
                        <div class="mt15 i-q-txt">
                          <p
                            class="c-999 f-fA"
                          >{{teacher.intro}}</p>
                        </div>
                      </section>
                    </li>
                    
                  </ul>
                  <div class="clear"></div>
                </article>
                <section class="tac pt20">
                  <a href="#" title="全部讲师" class="comm-btn c-btn-2">全部讲师</a>
                </section>
              </div>
            </section>
          </div>
          <!-- /网校名师 结束 -->
        </div>
      </div>
    </template>

    <script>
    import index from '@/api/index'
    export default {
      data(){
        return {
          courseList:[],
          teacherList:[]

        }
      },
      created(){

      },
      methods:{
        getHotCourseAndTeacher(){
          index.index()
            .then(response=>{
              this.courseList=response.data.data.CourseList
              this.teacherList=response.data.data.TeacherList
            })
        }

      }
      
    }
    </script>
  • 相关阅读:
    用到的一些方法
    Android屏蔽Home键
    Android自定义GridView显示一行,并且可以左右滑动
    模糊匹配字母大小写
    Android四大组件之Content Provider的学习
    用于小数据存储的SharedPreferences
    Android小知识点
    【译】用C/C++操作链表
    和好友的QQ记录,多关注哈需要关怀的人
    岁不待人_20080321
  • 原文地址:https://www.cnblogs.com/dmzna/p/12851573.html
Copyright © 2020-2023  润新知