当前位置:网站首页>Uni app wechat applet search keywords are displayed in red
Uni app wechat applet search keywords are displayed in red
2022-07-27 02:38:00 【liuye066】

Search keywords are marked in red
Modify the style of some characters in the string :
async getProductList() {
uni.showLoading({
title: ' Asking for ...'
})
let resPro = await getProducts({
keyword: this.keyword,
cate_id: this.currentCateId,
id: this.pro
})
// Handle the label style in the returned data
if(Object.keys(resPro).length != 0) {
resPro.forEach((item,index)=>{
if(item.hasOwnProperty('withTags')) {
item.withTags.forEach((subItem,idx)=> {
if(subItem.product_tag.indexOf(this.keyword) != -1) {
subItem.product_tag = this.join(subItem.product_tag,this.keyword)
}
})
}
});
}
this.productList = resPro
console.log('getProductList',this.productList)
uni.hideLoading()
},
// Splicing
join(str,key){
var reg = new RegExp((`(${key})`), "gm");
var replace = '<span style="color:#FD463E;font-weight:bold;">$1</span>';
return str.replace(reg, replace);
},Show :
<u-tag v-for="(vo,key) in item.withTags" :key="key" :text="vo.product_tag" :keyName="keyword"
color="#414141" bgColor="#eaebeb" borderColor="#eaebeb" shape="circle" size="mini" type="warning">
</u-tag>u-tag.vue
<!-- <text
class="u-tag__text"
:style="[textColor]"
:class="[`u-tag__text--${type}`, plain && `u-tag__text--${type}--plain`, `u-tag__text--${size}`]"
>{
{ text}} </text> -->
<rich-text
:nodes="text"
class="u-tag__text"
:style="[textColor]"
:class="[`u-tag__text--${type}`, plain && `u-tag__text--${type}--plain`, `u-tag__text--${size}`]"
> </rich-text>In the original <text> Cannot display normally in . The label and style will be displayed or the content will not be displayed . stay <rich-text> Medium nodes It can be displayed normally
边栏推荐
猜你喜欢
随机推荐
f8抓交通、f9抓兔子、f10turtle
【用C语言绘制谢尔宾斯基三角形】
After working in Tencent testing post for 5 years, I was ruthlessly dismissed in July, trying to wake up my brother who was still paddling
HCIP-第一天
LeetCode->二分查找打卡
C语言 学生信息管理系统 基于数组 可以存取到文本文件
转:俞敏洪:阻碍你成长的,是你自己
【洋哥带你玩转线性表(三)——双向链表】
How many holes have you stepped on in BigDecimal?
N methods of SQL optimization
php+swoole
go语言慢速入门——go运算符
[brother Yang takes you to play with the linear table (III) - two way linked list]
C language student information management system can access text files based on arrays
小程序utils
30岁被裁,我想明白的几件事....
见证中国网安力量 “解码2022中国网安强星”即将启航
【你了解Cache吗——全面理解高速缓冲存储器】
Go language slow start -- go operator
Fist guessing applet based on Object-C novice on the road









![[brother Yang takes you to play with the linear table (III) - two way linked list]](/img/64/5367ff4fb6797565cb1f9e1a8aee4e.png)