2014-12-06 256 views
0

我一直試圖添加語法突出顯示到我的web應用程序,並找到王牌。但是,在使用文檔中提供的解決方案之後,我仍然無法更改編輯器主題。有誰知道如何去做這件事?如何在Ace編輯器中更改主題?

+1

你到目前爲止得到了什麼代碼? – 2014-12-06 20:05:12

+0

@YuliaV到目前爲止,我剛剛用以下代碼初始化元素:var editor = ace.edit(「editor」); editor.getSession()。setUseWrapMode(true); editor.setHighlightActiveLine(true); editor.setShowPrintMargin(false); editor.setTheme('ace-builds-master/theme/tomorrow_night.css'); (「ace/mode/javascript」);' – mattd 2014-12-06 20:09:57

+1

@ user3785038你在哪裏找到了將'tomorrow_night.css'傳遞給setTheme的代碼片段?你也可以將你的評論中的代碼片段移動到問題中。 – 2014-12-15 22:15:05

回答

1

在構建模式參數setTheme()不是一個路徑,但爲主題的ID,所以你需要調用 .setTheme('ace/theme/tomorrow_night')代替

請注意,您甌可以使用設置在一個呼叫中的所有選項

editor.setOptions({ 
    useWrapMode: true, 
    highlightActiveLine: true, 
    showPrintMargin: false, 
    theme: 'ace/theme/tomorrow_night', 
    mode: 'ace/mode/javascript' 
}) 
+0

無法在src中的editor.js或edit_session.js文件中找到setOptions方法,該方法的確切位置 – PirateApp 2017-12-06 06:31:03

+0

沒關係,只是發現它感謝您的幫助 – PirateApp 2017-12-06 06:35:02