Question

Je teste ci-dessous le code d'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();

Le problème est que le contenu du texte contient comme ci-dessous :valeur:'La première ligne La deuxième ligne',

et il y aura une erreur :Erreur de syntaxe:chaîne non terminée littérale

Mais je dois afficher une nouvelle ligne dans textarea .Quelles sont les bonnes solutions pour cela ?

BTW, ce problème est causé par le rendu du panneau d'arborescence :

J'ai une méthode de rendu comme ci-dessous dans 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>' : '';
   }

Donc, si le contenu des journaux , il obtiendra ERREUR - SyntaxError :chaîne non terminée littérale

Était-ce utile?

La solution

Dans le paramètre « éléments » :le texte n'est pas correct, le « sous-paramètre » de « zone de texte », la « valeur » est correcte.C'était ça le problème.Le bon code est :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();

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top