gpt4 book ai didi

javascript - javascript 中的换行符\n 不起作用

转载 作者:行者123 更新时间:2023-11-28 04:45:08 25 4
gpt4 key购买 nike

我正在尝试使用 Angular 使用范围在 javascript 中进行换行,以便它使用 ionic 显示在我的前端中。但这不起作用。还有另一种方法可以打破这一点吗?

$scope.pick= [
{
name:"Fear",
line:"\n\u2022 Do what you are afraid of doing...\n over and over."
}]

html

  <div class="list">
<div class="item item-input item-select">
<div class="input-label">

</div>

<select ng-model="tab" ng-init="tab=pick[0]" ng-options="tab.name for tab in pick"></select>
</div>

<div class="list list-inset">
<div class="item">

<input type="text" ng-model="tab.line" id="displaycard">


<input type="text" ng-model="tab.line2" id="displaycard">

<input type="text" ng-model="tab.line3" id="displaycard">

</div>
</div>

</div>

尝试过

    var somebreak = '<br />' + '\u2022 Do what you are afraid of doing...' + 
'<br />'+ 'over and over.'

$scope.pick= [{
{
name:"Fear",
line: somebreak,
}]

并尝试过

     line:"<br/>\u2022 Do what you are afraid of doing...<br/> over and over.",

它仍然吐出这个。 enter image description here

最佳答案

按如下所述分配字符串值,并使用数组中的变量来保持其干净

var someVar = '<br />' + '\u2022 Do what you are afraid of doing...' + '<br />'+ 'over and over.'

$scope.pick= [ {
name:"Fear",
line:someVar }]

关于javascript - javascript 中的换行符\n 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43446848/

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