Skip to content

Commit c41574f

Browse files
committed
文章搜索 - 显示推荐搜索
1 parent 1d3f529 commit c41574f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

project/imooc-blog/api/search.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* @Date: 2021-12-21 21:21:21
3+
* @LastEditTime: 2021-12-21 21:21:23
4+
* @FilePath: \imooc-blog\api\search.js
5+
*/
6+
import request from "@/utils/request";
7+
8+
/**
9+
* 默认搜索内容
10+
*/
11+
export function getDefaultText() {
12+
return request({
13+
url: "/search/default-text",
14+
});
15+
}

project/imooc-blog/subpkg/pages/search-blog/search-blog.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
* @Date: 2021-12-21 16:33:53
3-
* @LastEditTime: 2021-12-21 20:44:59
3+
* @LastEditTime: 2021-12-21 21:22:21
44
* @FilePath: \imooc-bloge:\BlogDemo\imooc-uni-app\project\imooc-blog\subpkg\pages\search-blog\search-blog.vue
55
-->
66
<template>
@@ -25,6 +25,7 @@
2525
</template>
2626

2727
<script>
28+
import { getDefaultText } from "@/api/search";
2829
export default {
2930
data() {
3031
return {
@@ -34,6 +35,9 @@ export default {
3435
defaultText: "默认的 placeholderText",
3536
};
3637
},
38+
created() {
39+
this.loadDefaultText();
40+
},
3741
methods: {
3842
/**
3943
* 搜索内容
@@ -63,6 +67,13 @@ export default {
6367
onSearchCancel(val) {
6468
console.log("searchbar 取消按钮");
6569
},
70+
/**
71+
* 获取推荐搜索文本
72+
*/
73+
async loadDefaultText() {
74+
const { data: res } = await getDefaultText();
75+
this.defaultText = res.defaultText;
76+
},
6677
},
6778
};
6879
</script>

0 commit comments

Comments
 (0)