aabbcc/src/views/labelPage.vue
2024-06-15 16:53:22 +08:00

180 lines
3.4 KiB
Vue

<template>
<div>
<header>
<navigationBar />
</header>
<main class="main-content">
<section class="box w">
<header class="box-hd">
<h3>课程笔记</h3>
</header>
<div class="box-bd">
<ul class="clearfix">
<li v-for="(item, index) in items" :key="index">
<router-link :to="`/paiListPage/${index + 1}`">
<!-- 这里的index + 1对应着表的序号 -->
<img :src="item.url" :alt="item.title" />
<h4>{{ item.title }}</h4>
</router-link>
</li>
</ul>
</div>
</section>
</main>
<div class="add">
<button @click="openDialog">添加笔记</button>
</div>
<!-- 添加笔记弹窗 -->
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
<el-form ref="form" :model="form" label-width="80px" :rules="rules">
<el-form-item label="笔记标题" prop="addContent">
<el-input v-model="form.addContent"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleAdd"> </el-button>
</span>
</el-dialog>
<musIc />
</div>
</template>
<script>
import { getTags } from '@/api/tags'
export default {
data () {
return {
items: [],
dialogVisible: false,
form: {
addContent: ''
},
rules: {
addContent: [
{ required: true, message: '请输入标题', trigger: 'blur' }
]
}
}
},
created () {
this.fetchTags()
},
methods: {
fetchTags () {
getTags().then((res) => {
this.items = res.data
})
},
openDialog () {
this.dialogVisible = true
},
handleAdd () {
this.dialogVisible = false
this.$message({
message: '添加成功',
type: 'success'
})
this.form.addContent = ''
}
}
}
</script>
<style lang="less" scoped>
.w {
width: 1200px;
margin: auto;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
/* .clearfix {
*zoom:1;
} */
.clearfix img {
width: 100%;
height: 220px;
display: block;
}
.box {
margin-top: 80px;
border-bottom: 1px solid #d3d3d3;
}
.box-hd {
height: 45px;
}
.box-hd h3 {
float: left;
font-size: 20px;
color: #494949;
}
/* 把li 的父亲ul 修改的足够宽一行能装开5个盒子就不会换行了 */
.box-bd ul {
width: 1225px;
}
.box-bd ul li {
position: relative;
top: 0;
float: left;
width: 228px;
height: 270px;
background-color: #fff;
margin-right: 15px;
margin-bottom: 15px;
transition: all 0.3s;
}
.box-bd ul li a {
display: block;
}
.box-bd ul li:hover {
top: -8px;
box-shadow: 0 15px 30px rgb(0 0 0 / 10%);
}
.box-bd ul li img {
width: 100%;
}
.box-bd ul li h4 {
margin: 20px 20px 20px 25px;
font-size: 14px;
color: #050505;
font-weight: 400;
}
.box-bd ul li:hover h4 {
color: #006cff;
}
.add {
position: fixed;
bottom: 100px;
right: 20px;
button {
background-color: #006cff;
color: #fff;
border: none;
width: 100px;
height: 40px;
border-radius: 30px;
font-size: 16px;
cursor: pointer;
}
}
</style>