要設(shè)置UEditor的默認內(nèi)容和格式,可以通過以下幾種方法:
var ue = UE.getEditor('editor', {
initialContent: '這是默認內(nèi)容', // 設(shè)置默認內(nèi)容
initialStyle: 'body {font-size: 16px; color: #333;}' // 設(shè)置默認格式
});
var ue = UE.getEditor('editor');
ue.ready(function() {
ue.setContent('這是默認內(nèi)容'); // 設(shè)置默認內(nèi)容
ue.execCommand('insertHtml', '<style>body {font-size: 16px; color: #333;}</style>'); // 設(shè)置默認格式
});
可以在config.js文件中設(shè)置默認內(nèi)容和格式:
// config.js
UE.Editor.prototype.defaultContent = '這是默認內(nèi)容'; // 設(shè)置默認內(nèi)容
UE.Editor.prototype.defaultStyle = 'body {font-size: 16px; color: #333;}'; // 設(shè)置默認格式
以上是三種常見的設(shè)置UEditor默認內(nèi)容和格式的方法,您可以根據(jù)自己的需求選擇合適的方法來設(shè)置默認內(nèi)容和格式。