vue处理换行符
1.处理换行符
<tr class="unread" v-for="(item,index) in DataList" :key="index">
<td class="salesUnitName">{{item.salesUnitName}}</td>
<td class="createUserName">{{item.createUserName}}</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>
<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){
return val.replace(/\n/g,"<br/>")
},
直接使用val.replace会报错,查一下replace用法,就知道stringObject.replace(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/>")
},
vue处理换行符的更多相关文章
- Vue 中 换行符获取
当要获取到 vue 中 文本域的换行符时, 需要用到正则匹配. let reg = new RegExp('/n',"g"); let str = text.replace(reg ...
- SQL:指定名称查不到数据的衍伸~空格 换行符 回车符的批量处理
异常处理汇总-数据库系列 http://www.cnblogs.com/dunitian/p/4522990.html 先看看啥情况 复制查询到的数据,粘贴一下看看啥情况 那就批量处理一下~ 就这样 ...
- c#使用Split分割换行符 \r\n
c# 使用Split分割 换行符,方法如下(其余方法有空再添加): string str = "aa" + "\r\n" + "bb"; ...
- (转载)SQL去除回车符,换行符,空格和水平制表符
http://www.cnblogs.com/insus/p/4815336.html MS SQL去除回车符,换行符,空格和水平制表符,参考下面语句,一般情况是SQL接受富文本或是textarea的 ...
- Log4net中换行符
在log4net节点中 <appender name="DebugLogFileAppender" type="log4net.Appender.FileAppen ...
- php换行符
1.需求 统一php换行符 2.实践 使用PHP_EOL替换换行符,保证平台的兼容性. 类似的有DIRECTORY_SEPARATOR 参考文档:http://www.cnblogs.com/code ...
- handlebars.js 用 <br>替换掉 内容的换行符
handlebars.js 用 <br>替换掉 内容的换行符 JS: Handlebars.registerHelper('breaklines', function(text) { te ...
- linux下与windows下的换行符
[原文有些许错误,已作了修改] 回车符号和换行符号产生背景 关于“回车”(carriage return)和“换行”(line feed)这两个概念的来历和区别.在计算机还没有出现之前,有一种叫做电传 ...
- 【转】去掉Sqlite3 数据库中的前后回车换行符(newline)
原文: http://www.blogjava.net/pts/archive/2013/06/10/400... 时间: 2013-06-10 转自:http://www.ityuedu.com/a ...
随机推荐
- jmeter 分布式配置(含参数化问题)
这次用的是 jmeter 5.1.1 jdk8 调度机: 修改bin目录下jmeter.properties文件 第258行 remote_hosts=192.168.87.34:1856,192. ...
- 123457123456#0#-----com.threeapp.SuanShuXiaoTianCai01----数学算术小天才
com.threeapp.SuanShuXiaoTianCai01----数学算术小天才
- 123457123456#0#---com.threeapp.ErTongShuXueKoSuan01----儿童宝宝数学口算01
com.threeapp.ErTongShuXueKoSuan01----儿童宝宝数学口算01
- PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)
1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other ...
- LeetCode_121. Best Time to Buy and Sell Stock
121. Best Time to Buy and Sell Stock Easy Say you have an array for which the ith element is the pri ...
- 手动mvn install指令向maven本地仓库安装jar包
mvn install:install-file -DgroupId=imsdriver(jar包的groupId) -DartifactId=imsdriver(jar包的artifactId) - ...
- 第十七章 OAuth2集成——《跟我学Shiro》
目录贴:跟我学Shiro目录贴 目前很多开放平台如新浪微博开放平台都在使用提供开放API接口供开发者使用,随之带来了第三方应用要到开放平台进行授权的问题,OAuth就是干这个的,OAuth2是OAut ...
- leetcode903 Valid Permutations for DI Sequence
思路: dp[i][j]表示到第i + 1个位置为止,并且以剩下的所有数字中第j + 1小的数字为结尾所有的合法序列数. 实现: class Solution { public: int numPer ...
- go json解析Marshal和Unmarshal
Decoder: package main import ( "encoding/json" "fmt" "io" "log&qu ...
- mysql支持emoji表情符存储
一.教你如何让数据库支持emoji表情符存储 解决方式: 更换字符集utf8-->utf8mb4 问题描述: 前台应用抓取微博信息,每天总有几条数据插入不成功.应用日志显示: java.sql. ...