Commit 4026b27a authored by Damon's avatar Damon

fix: 【ID1001459】【小程序-首页-试题搜索】:搜索结果中题干中的关键字未高亮显示

parent 845e474d
......@@ -2,8 +2,8 @@
<view @click.stop="itemChange(item.id)" class="list-item">
<view :class="['u-flex', 'head', { selected: item.id === arrIndex }]">
<view class="titles">
<text>{{ item.type }}</text
>{{ item.title }}
<view class="type">{{ item.type }}</view>
<u-parse :html="keyword, item.title | toRed"></u-parse>
</view>
<view class="u-flex arrow" v-show="item.id !== arrIndex">
<text>展开</text>
......@@ -56,7 +56,7 @@ export default {
answerSheet,
answerExplanation,
},
props: ['item', 'arrIndex'],
props: ['item', 'arrIndex', 'keyword'],
computed: {
collectImg() {
const name = this.item?.collectionFlag ? 'collected.png' : 'collect.png'
......@@ -66,6 +66,12 @@ export default {
return this.item?.collectionFlag || false
},
},
filters:{
toRed:function(content, keyword) {
const reslut = keyword.replace(''+content+'', "<text style='color:red'>"+content+"</text>")
return reslut
},
},
methods: {
itemChange(id) {
this.$emit('arrowDown', id)
......@@ -98,13 +104,17 @@ export default {
flex: 1;
height: 60rpx;
overflow: hidden;
text {
.type {
background: #9ea5bb;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
margin: 10rpx 10rpx 0 0;
font-size: 20rpx;
border-radius: 50rpx 0 50rpx 50rpx;
float: left;
height: 45rpx;
line-height: 45rpx;
width: 100rpx;
text-align: center;
}
}
.arrow {
......
......@@ -33,6 +33,7 @@
:begin="item.begin"
:arrId.sync="arrId"
:end="item.end"
:keyword="keyword"
></my-section>
<u-loadmore :status="loadStatus" :margin-bottom="40" />
</view>
......
......@@ -5,6 +5,7 @@
:key="index"
:item="item"
:arrIndex.sync="arrIndex"
:keyword.sync="keyword"
@arrowDown="arrowDown"
@arrowUp="arrowUp"
@collection="collection($event, index)"
......@@ -20,7 +21,7 @@ export default {
components: {
searchItem,
},
props: ['begin', 'end', 'arrId'],
props: ['begin', 'end', 'arrId', 'keyword'],
data() {
return {
list: [],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment