문제

extjs5의 코드 아래를 테스트하십시오 :

Ext.create('Ext.window.Window', {
        title: 'try extjs text area',
        width: 900,
        height: 500,
        layout: 'fit',
        items: [{ 
            xtype: 'textarea',
            value: ' The first line \n The second line',
            border: true,
            autoScroll: true,
            draggable: true
        }]
     }
    ).show();
.

이 문제는 다음과 같이 \n에 포함 된 텍스트 내용입니다. 가치 : '첫 번째 줄 \n두 번째 줄',

오류가 발생합니다. syntaxerror : unterminated string 리터럴

그러나 TextArea에서 새로운 라인을 표시해야합니다.이것에 대한 올바른 솔루션은 무엇입니까?

btw,이 문제는 트리 패널 렌더링으로 인해 발생합니다 :

maincontroller.js에서 아래의 렌더링 방법이 있습니다.

    renderLogs: function (logs, p, record) {
     return logs?  '<div><img src="default-more.png" /
       onclick="Ext.create(\'Ext.window.Window\', /
         { title: \'try extjs text area\', /
           width: 900,height: 500, /
           layout: \'fit\', /
           items: [{xtype: \'textarea\', /
           value: \'"+logs+"\', /
           border: true,autoScroll: true,draggable: true}]}).show(); "> /
      </img></div>' : '';
   }
.

그래서 \n에 로그온하면 오류가 발생합니다 - syntaxerror : unterminated string literal

도움이 되었습니까?

해결책

'항목'매개 변수 : 텍스트는 'textArea'의 'sub-parameter'가 올바르지 않습니다. '값'이 올바른 것입니다.그게 문제 였어.올바른 코드는 다음과 같습니다. Ext.create('Ext.window.Window', { title: 'try extjs text area', width: 900, height: 500, layout: 'fit', items: { xtype: 'textarea', value: ' The first line \n The second line', border: true, autoScroll: true, draggable: true }} ).show();

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top