亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ace 編輯器寬度更改會丟失內容

ace 編輯器寬度更改會丟失內容

慕尼黑5688855 2022-09-02 11:07:41
我需要能夠在用戶將代碼放入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>展開代碼段從上面的例子中可以看出,我在縮小編輯器時丟失了很多文本!我看不到任何與寬度相關的基本設置來解決這個問題,我是否缺少一種簡單的方法來在調整大小后將所有文本保留在編輯器中?我目前正在想,我可以在調整大小后重新創建整個編輯器,但這顯然不理想。
查看完整描述

1 回答

?
Cats萌萌

TA貢獻1805條經驗 獲得超9個贊

更改寬度后,您需要調用editor.resize()



查看完整回答
反對 回復 2022-09-02
  • 1 回答
  • 0 關注
  • 197 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號