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' import request from '../utils/request'
export function getlist (data) { export function getlist (id) {
return request({ return request({
url: '/tags/:id', url: `/list/${id}`,
method: 'get', method: 'get',
data: data params: { id }
}) })
} }

View File

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

View File

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

View File

@ -11,8 +11,8 @@
</header> </header>
<div class="box-bd"> <div class="box-bd">
<ul class="clearfix"> <ul class="clearfix">
<li v-for="(item, index) in items" :key="index"> <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" /> <img :src="item.url" :alt="item.title" />
<h4>{{ item.title }}</h4> <h4>{{ item.title }}</h4>
</router-link> </router-link>
@ -26,38 +26,7 @@
<button @click="openDialog">添加笔记</button> <button @click="openDialog">添加笔记</button>
</div> </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> </div>
</template> </template>
@ -82,17 +51,14 @@ export default {
} }
}, },
created () { created () {
this.fetchNote() this.fetchTags()
}, },
methods: { methods: {
fetchNote () { fetchTags () {
getTags().then(res => { getTags().then(res => {
this.items = res.data this.items = res.data
}) })
}, },
open () {
// this.drawer = true
},
openDialog () { openDialog () {
this.dialogVisible = true this.dialogVisible = true
}, },

View File

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