Skip to content

Commit e96f11f

Browse files
committed
热搜列表 - 热搜点击处理
1 parent 5472697 commit e96f11f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

project/imooc-blog/components/search-hot-list/search-hot-list.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!--
22
* @Date: 2021-12-21 21:51:50
3-
* @LastEditTime: 2021-12-22 17:36:31
3+
* @LastEditTime: 2021-12-22 17:59:27
44
* @FilePath: \imooc-blog\components\search-hot-list\search-hot-list.vue
55
-->
66
<template>
77
<view class="search-hot-list-container">
88
<!-- 标题 -->
99
<view class="search-hot-title">慕课热搜 - 全网技术 一网打尽</view>
1010
<block v-for="(item, index) in hotList" :key="index">
11-
<view class="search-hot-item">
11+
<view class="search-hot-item" @click="onItemClick(item)">
1212
<!-- 序号 -->
1313
<hot-ranking :ranking="index + 1"></hot-ranking>
1414
<!-- 文本 -->
@@ -46,6 +46,12 @@ export default {
4646
this.hotList = res.list;
4747
console.log(this.hotList);
4848
},
49+
/**
50+
* item 点击事件
51+
*/
52+
onItemClick(item) {
53+
this.$emit("onSearch", item.label);
54+
},
4955
},
5056
};
5157
</script>

project/imooc-blog/styles/global.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
word-break: break-all;
1515
}
1616

17+
.line-clamp {
18+
white-space: normal;
19+
overflow: hidden;
20+
text-overflow: ellipsis;
21+
display: -webkit-box;
22+
-webkit-box-orient: vertical;
23+
-webkit-line-clamp: 1;
24+
word-break: break-all;
25+
}
26+
1727
// 卡片视图
1828
.card {
1929
border: 1px solid #f9f9f9;

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

Lines changed: 2 additions & 2 deletions
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-22 17:35:06
3+
* @LastEditTime: 2021-12-22 18:00:12
44
* @FilePath: \imooc-bloge:\BlogDemo\imooc-uni-app\project\imooc-blog\subpkg\pages\search-blog\search-blog.vue
55
-->
66
<template>
@@ -24,7 +24,7 @@
2424
<!-- 热搜列表 -->
2525
<view class="search-hot-list-box card" v-if="showType === HOT_LIST">
2626
<!-- 列表 -->
27-
<search-hot-list />
27+
<search-hot-list @onSearch="onSearchConfirm" />
2828
</view>
2929
<!-- 搜索历史 -->
3030
<view class="search-history-box" v-else-if="showType === SEARCH_HISTORY">

0 commit comments

Comments
 (0)