此代碼僅將資訊重新添加到第一個塊:
window.onload = function(e) {
document.querySelectorAll(".codemirror-textarea").forEach(el => {
const [output] = document.querySelectorAll(".codemirror-textarea");
const editor = CodeMirror.fromTextArea(output, {lineNumbers: true, readOnly: true});
});}
uj5u.com熱心網友回復:
您正在回圈元素,但每次都將 CodeMirror 應用于第一個元素,請在回圈中使用 el 。
window.onload = function(e) {
document.querySelectorAll(".codemirror-textarea").forEach(el => {
const editor = CodeMirror.fromTextArea(el, {lineNumbers: true, readOnly: true});
});
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/494817.html
標籤:javascript html
上一篇:Uncaught(inpromise)TypeError:Cannotreadpropertiesofundefined(reading'language')
