-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiaochaochao
committed
Feb 4, 2024
1 parent
67e40d5
commit c583912
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
order: 3 | ||
--- | ||
# 布局 | ||
|
||
## 编辑器大小 | ||
在create编辑时,通过配置 [automaticLayout](../editor/interfaces/IStandaloneDiffEditorConstructionOptions.md#automaticlayout) 实现编辑器大小自适应: | ||
``` javascript | ||
monaco.editor.create(editorRef.value, { | ||
value: '', | ||
language: "javascript", | ||
fixedOverflowWidgets: true, | ||
fontFamily: "Arial", | ||
fontSize: 14, | ||
readOnly: true, | ||
tabSize: 8, | ||
insertSpaces: true, | ||
wordWrap: 'on', | ||
wordWrapColumn: 120, | ||
// 默认值为false | ||
automaticLayout: true, | ||
}); | ||
``` | ||
|
||
::: danger | ||
|
||
这个属性设置设置为 true ,则编辑器会在窗口大小发生变化时自动调整大小以适应新的窗口大小。 所以需要注意的是,如果有类似于侧边栏菜单关闭和展开的逻辑,一定要保证编辑器的容器盒子能够自使用宽度变化,否则无法触发编辑器的自适应 | ||
|
||
::: |