This commit is contained in:
username 2024-05-27 21:26:22 +08:00
parent 8c4bc4485e
commit a291cddecd
5 changed files with 26 additions and 58 deletions

View File

@ -1,9 +1,9 @@
import request from '../utils/request'
export function getlist (data) {
export function getlist (id) {
return request({
url: '/tags/:id',
url: `/list/${id}`,
method: 'get',
data: data
params: { id }
})
}

View File

@ -78,7 +78,7 @@ export default {
// Vuex
this.$store.commit('logout')
//
this.$router.push({ path: '/login' })
this.$router.push({ path: '/' })
this.$message({
message: '退出成功',
type: 'success'

View File

@ -136,7 +136,7 @@ const routes = [
// name: 'pythonContent',
// component: pythonContent
// },
{ path: '/note/:id', component: NoteDetail }
{ path: '/list/:id', component: NoteDetail }
]
const router = new VueRouter({

View File

@ -12,7 +12,7 @@
<div class="box-bd">
<ul class="clearfix">
<li v-for="(item, index) in items" :key="index" >
<router-link :to="`/tags/${item.id}`">
<router-link :to="`/list/${index + 1}`"> <!-- 这里的index + 1对应着表的序号 -->
<img :src="item.url" :alt="item.title" />
<h4>{{ item.title }}</h4>
</router-link>
@ -26,38 +26,7 @@
<button @click="openDialog">添加笔记</button>
</div>
<el-dialog title="提示" :visible.sync="dialogVisible" width="50%">
<el-form ref="form" :model="form" :rules="rules" label-width="230px" :inline="true" >
<el-form-item label="标题" prop="addContent">
<el-input v-model="form.addContent"></el-input>
</el-form-item>
<el-upload
class="upload-demo"
drag
action="https://jsonplaceholder.typicode.com/posts/"
multiple
style="text-align: center"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">
只能上传jpg/png文件且不超过500kb
</div>
</el-upload>
</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>
<el-drawer title="我是标题" :visible.sync="drawer" :direction="direction">
<span>我来啦!</span>
</el-drawer>
<musIc />
<!-- 其他代码 -->
</div>
</template>
@ -82,17 +51,14 @@ export default {
}
},
created () {
this.fetchNote()
this.fetchTags()
},
methods: {
fetchNote () {
fetchTags () {
getTags().then(res => {
this.items = res.data
})
},
open () {
// this.drawer = true
},
openDialog () {
this.dialogVisible = true
},

View File

@ -1,34 +1,36 @@
<template>
<div class="note-detail">
<h1>{{ note.title }}</h1>
<!-- 显示笔记内容的其它元素 -->
<div>
<main class="main-content">
<!-- 显示详情内容 -->
<div v-html="detailContent"></div>
</main>
</div>
</template>
<script>
import { getlist } from '@/api/list'
export default {
name: 'liSt',
data () {
return {
note: {} //
detailContent: '' //
}
},
created () {
this.getList()
this.fetchContent() //
},
methods: {
getList () {
const id = this.$route.query.id
getlist(id).then(res => {
console.log(res)
this.note = res.data
fetchContent () {
const id = this.$route.params.id // ID
// ID
getlist(id).then(response => {
//
this.detailContent = response.data[0].content //
}).catch(error => {
console.error('Error fetching content:', error)
})
}
},
watch: {
'$route.query.id': 'fetchData'
}
}
</script>