[TOC]
设置基本布局结构,底部列表使⽤ Element 的 Tree 组件,后续通过属性配置可以直接设置拖拽功能。
设置 draggable 实现列表项拖拽
class=“course-section”>
:data=“data”
:props=“defaultProps”
draggable
>
export default {
name: ‘CourseSection’,
props: {
courseId: {
type: [String, Number],
required: true
}
},
data () {
return {
data: [{
label: ‘⼀级 1’,
children: [{
label: ‘⼆级 1-1’,
children: [{
label: ‘三级 1-1-1’
}]
}]
},
{
label: ‘⼀级 2’,
children: [{
label: ‘⼆级 2-1’,
children: [{
label: ‘三级 2-1-1’
}]
}, {
label: ‘⼆级 2-2’,
children: [{
label: ‘三级 2-2-1’
}]
}]
}, {
label: ‘⼀级 3’,
children: [{
label: ‘⼆级 3-1’,
children: [{
label: ‘三级 3-1-1’
}]
}, {
label: ‘⼆级 3-2’,
children: [{
label: ‘三级 3-2-1’
}]
}]
}],
defaultProps: {
children: ‘children’,
label: ‘label’
}
}
}
}
请求数据创建列表内容,接⼝为章节内容 -> getSessionAndLesson 接⼝。
// services/course-section.js (新建)
import request from ‘@/utils/request’
// 获取章节和课时
export const getSectionAndLesson = courseId => {
return request({
method: ‘GET’,
url: ‘/boss/course/section/getSectionAndLesson’,
params: {
courseId
}
})
}
引⼊并使⽤
slot=“header”>
课程名称