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