今天在做搜索接口的时候,出现这样一个bug
查了接口,不是接口的错误,排除了后端错误
最后通过查询路径发现他的路径请求路径给我打错了,打成了/searchvideolist?mysearch宠物,证明是请求路径写错了
之前的
现在的,加上一个=就好了
let url = "/searchvideolist?mysearch"+"="+this.id;
正确版本的源码:
<template> <div style="margin-right: 4%;display: flex;flex-wrap:wrap;align-content:space-between;"> <el-col :span="5" v-for="item in videoList" :key="item.id" :offset="1" style="margin-bottom: 25px;"> <el-card :body-style="{ padding: '0px' }" style="padding-bottom: 17px"> <router-link :to="'/video?video=' + item.id" style="line-height: 0;color: black;text-decoration:none;"> <img :src="getImgURL(item.id)" style="margin-bottom: 7px;"> <!-- <template #footer>{{ item.name }}</template> --> <!-- <p>{{ item.name }}</p> --> <!-- <template #footer>Footer content</template> --> <span style="line-height: 17px;">{{item.name}}</span> </router-link> </el-card> </el-col> </div> </template> <script> import axios from "axios"; export default { name: "searchView", data(){ return{ id:"", videoList:[] } }, methods:{ GetVideoList(){ let url = "/searchvideolist?mysearch"+"="+this.id; console.log(url) axios.get(url).then((res) => { this.videoList = res.data; }) }, getImgURL(imgId){ return "http://localhost:9090/static/img/"+ imgId + ".jpg" } }, mounted(){ this.id = localStorage.getItem("searchid"); this.GetVideoList(); } } </script> <style> </style>