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;
将传入的字符串,直接变量名使用!

猜你喜欢

转载自www.cnblogs.com/jiqing9006/p/10388249.html
今日推荐