gpt4 book ai didi

html - 如何显示带有换行符的文本

转载 作者:太空狗 更新时间:2023-10-29 15:23:22 28 4
gpt4 key购买 nike

enter image description here

我需要显示带有换行符的文本,这是脚本

<script>
var app = angular.module('MyApp', []);
app.controller('Ctrl', function ($scope) {
console.log('Controller is executed');
$scope.btnClick = function () {
console.log($scope.desc);
}
$scope.ShowData = function () {
$scope.text = $scope.desc;
}
});
</script>

这是html代码

<body ng-controller="Ctrl">
<form>
<textarea ng-model="desc" cols="105" rows="15"></textarea>
<button ng-click="btnClick()">Submit</button>
<button ng-click="ShowData()">Show</button>
</form>
<div ng-bind="text"></div>

最佳答案

尝试在 <pre></pre> 中渲染文本标记而不是 <div> .或者使用 style="white-space:pre-wrap;"在你的 div 上。

关于html - 如何显示带有换行符的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42973055/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com