JS 字符串 作為變量名


function initCKEditor(querySelector,content_val,myEditor) {
    ClassicEditor.create(document.querySelector(querySelector), {
        toolbar: ["undo", "redo", "|", "alignment", "bold", "italic", "blockQuote", "imageTextAlternative", "imageUpload", "heading", "link", "numberedList", "bulletedList"],
        ckfinder: {
            uploadUrl: '/admin.php/Common/ck_editor?command=QuickUpload&type=Files&responseType=json'
        }
    }).then(editor => {
        // 設置初始值
        editor.setData(content_val);
        window[myEditor] = editor;
    }).catch(error => {
        console.error(error);
    });
}

window[myEditor] = editor;
將傳入的字符串,直接變量名使用!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM