Monaco-Editor:隐藏概览标尺

18

是否有办法完全隐藏Monaco编辑器中的概览标尺?即使使用以下代码,它仍然可见:

        overviewRulerLanes: 0,
        hideCursorInOverviewRuler: true,
        scrollbar: {
            vertical: 'hidden'
        },
        overviewRulerBorder: false,
3个回答

11

您是说 这个 吗?

如果是的话:

minimap: {enabled: false}


不,我的意思是滚动条,而不是缩略图。 - eprst
要隐藏小地图,需要在选项对象中进行设置。选项为:options={{ minimap: { enabled: false } }}。 - peter

7
如果您想隐藏滚动条,可以这样做:
const monacoInstance=monaco.editor.create(document.getElementById("editor"),{
    value:`console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");console.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");\nconsole.log("hello,world");`,
    language:"javascript",
    // theme:"vs-dark",
    readOnly:true,
    minimap:{enabled:false},
    overviewRulerLanes: 0,
    scrollbar: {
        vertical:"hidden",
        horizontal: "hidden",
        handleMouseWheel:false,
    },
    wordWrap: 'on',
})

我是这样使用它的<Editor height="80vh" defaultLanguage="javascript" defaultValue= {code} className=" overflow-hidden" />如何在React JS中解决这个问题。 - Ankit Kumar
@AnkitKumar 将相同的选项传递给 options 属性,像这样:<Editor ... options={{ scrollbar:{...} }} - Mohcine BAADI

4

根据您发布的设置,它应该可以正常工作。

        overviewRulerLanes: 0,
        hideCursorInOverviewRuler: true,
        scrollbar: {
            vertical: 'hidden'
        },
        overviewRulerBorder: false,

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接