我有一个包含换行符/n的字符串。尝试显示该字符串。但是它并不把/n作为新的一行,而是将其作为文本显示。
$scope.myOutput = " Hello /n"
{{ myOutput | textFormat }}
必填项 -> 你好(在html页面上)
尝试过:
app.filter('textFormat', function() {
return function(x) {
return x.replace(/\\n/g, '<br/>');
}
尝试过像 white-space: pre; 这样的 CSS 样式;