vue处理换⾏符
1.处理换⾏符
<tr class="unread" v-for="(item,index) in DataList" :key="index">
<td class="salesUnitName">{{item.salesUnitName}}</td>
<td class="createUserName">{{ateUserName}}</td>
<td class="halfContent" v-show="typeListVal == 4" v-html="keepTextStyle(item.domesticOpponentSituation)"></td>
<td class="halfContent" v-show="typeListVal == 4" v-html="keepTextStyle(item.overseaOpponentSituation)"></td>textstyle
<td class="allContent" v-show="typeListVal == 6" v-html="keepTextStyle(item.financeSituation)"></td>
<td class="allContent" v-show="typeListVal == 7" v-html="keepTextStyle(item.productDemand)"></td>
<td class="allContent" v-show="typeListVal == 8" v-html="keepTextStyle(item.marketSituation)"></td>
<td class="allContent" v-show="typeListVal == 9" v-html="keepTextStyle(item.humanResources)"></td>
<td class="allContent" v-show="typeListVal == 10" v-html="keepTextStyle(item.projectProgressSituation)"></td>
<td class="allContent" v-show="typeListVal == 11" v-html="keepTextStyle(item.workMatters)"></td>
</tr>
keepTextStyle(val){
place(/\n/g,"<br/>")
},
直接使⽤place会报错,查⼀下replace⽤法,就知道place(regexp/substr,replacement),所以stringObject必须是字符串才可以,犯了⼀个致命的错误是接受过来要的后台数据并不是string类型,所以报错了,改正如下即可(变成字符串)
keepTextStyle(val){
console.log(val)
console.log(typeof val)
console.log((typeof val)!='undefined')
return (val + '').replace(/\n/g,"<br/>")
},
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论