Commit 4026b27a authored by Damon's avatar Damon

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

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