需要一个固定的格式,比如@后面的文字加个空格@123123 速度放缓就卡死
页面显示
<div class="column_title">
<template v-for="(val, ind) in feedCount">
<div :key="ind">
<span v-if="val.b" class="ssss">{{ val.b }}</span>
<span v-if="val.c">{{ val.c }}</span>
<span v-if="val.e" class="ssss">{{ val.e }}</span>
<span v-if="val.f">{{ val.f }}</span>
<span v-if="val.j" class="ssss">{{ val.j }}</span>
</div>
</template>
</div>
使用
let feedCount = '@123123 速度放缓就卡死@1231234 #撒旦发几款'
_this.feedContent = strCur(feedCount)
封装字符串处理
//字符串处理分装
export function strCur(feedContent){
let a=''
let b=''
let c=''
let e=''
let f=''
let j=''
let d=[]
if(feedContent){
a = feedContent.split(' ')
a.map((val,index) => {
if(val.indexOf('@') > -1){
b = val.substr(0,val.indexOf('@'))
c = val.substr(val.indexOf('@'),val.length)+' '
e=''
f=''
j=''
}else if(val.indexOf('#')>-1){
b=''
c=''
e=val.substr(0,val.indexOf('#'))
f=val.substr(val.indexOf('#'),val.length)
j=''
}else{
b=''
c=''
e=''
f=''
j=val
}
d.push({
b:b,
c:c,
e:e,
f:f,
j:j
})
})
}
return d
}