我需要能夠在用戶將代碼放入ace編輯器后更改其寬度。但是,當我更改按住編輯器的div的寬度時,文本不會將自己換行到較薄的寬度中,您只是無法再看到它(請參閱 https://jsfiddle.net/0d4whvsq/1/)var editor = ace.edit("ace_editor_div");editor.getSession().setUseWorker(false);editor.setOptions({ maxLines: 50, minLines: 30, tabSize:2, wrap:true,});//editor.$blockScrolling = Infinity;editor.setValue("this is meant to be too much text for the width of the editor once the width is made smaller.")$("#shrink_button").on("click",function(){ $("#ace_editor_div").css("width","200px");});<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.min.js"></script><script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script><button id="shrink_button">shrink</button></button><div id="ace_editor_div"></div>展開代碼段從上面的例子中可以看出,我在縮小編輯器時丟失了很多文本!我看不到任何與寬度相關的基本設置來解決這個問題,我是否缺少一種簡單的方法來在調整大小后將所有文本保留在編輯器中?我目前正在想,我可以在調整大小后重新創建整個編輯器,但這顯然不理想。
ace 編輯器寬度更改會丟失內容
慕尼黑5688855
2022-09-02 11:07:41