使用monaco編輯器 報錯Can only have one anonymous define call per script file
問題描述:
開啟monaco編輯器後,再開啟含有amd載入方式的js檔案時,報錯 Can only have one anonymous define call per script file
原因分析:
這是因為monaco的資原始檔中有個判斷,不能一個專案中有兩個define的定義函式,因為monaco需要自己的定義。所以避免define方法互相汙染而報錯,或者資原始檔沒載入!
解決方案:
在create之後 加上
if(editor && "function" == typeof define && define.amd) {
delete define.amd;
}
雖然刪掉了amd屬性,對monaco也不會有影響。
我們看下下面webpack編譯後的檔案,這樣再載入這個檔案就不會走到define 的判斷裡面,所以不會再出現Can only have one anonymous define call per script file 這個報錯
相關文章
- Asp.Net Core 使用Monaco Editor 實現程式碼編輯器ASP.NET
- MongoDB報錯:"assertion" : "can't map file memory"MongoDB
- 前端工具 | JS編譯器Monaco使用教程前端JS編譯
- Swift代理報錯Optional can only be applied to members of an @objc protocolSwiftAPPOBJProtocol
- rsau/max_diskspace/per_file - Maximum size of one single security audit file
- "ScrollView can host only one direct child"問題解決View
- error C2713: Only one form of exception handling permitted per functionErrorORMExceptionMITFunction
- java.util.zip.ZipException:ZIP file must have at least one entryJavaExceptionAST
- Capture One 22 Pro 影像編輯轉換器APT
- [Oracle Script] Undo Usage Per statusOracle
- [Oracle Script] Undo Usage Per sessionOracleSession
- 錯誤處理--pure specifier can only be specified for functionsFunction
- 報錯:npm ERR! missing script: serve npm ERR! A complete log of this run can be found in:NPM
- why this draw call can‘t be batched with the previous one for Unity2019.4+BATUnity
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- SparkStreaming報錯: Only one SparkContext may be running in this JVM (see SPARK-2243)SparkContextJVM
- One very useful script
- Capture One 23 Pro Mac(RAW影像編輯轉換器)APTMac
- MySQl報錯之@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_MODE = ONMySql
- 報錯-only final is permittedMIT
- vim 編輯報錯導致無法正常退出和編輯
- 【React】Invalid hook call. Hooks can only be called inside of the body of a function component.ReactHookIDEFunction
- jdbc使用call呼叫儲存過程報錯JDBC儲存過程
- RAW影像編輯轉換器Capture One 22 Pro Mac/WindowsAPTMacWindows
- 簡報編輯器:Deckset Mac版Mac
- 作業系統報:read-only file system作業系統
- IMP-00013: only a DBA can import a file exported by another DBA 問題及解決方案ImportExport
- Can one rename a database user (schema)?Database
- for public synonym, only sys user can compile it?Compile
- Oracle ASM How many allocation units per fileOracleASM
- WPS公式編輯器顯示錯誤公式
- 線上編輯器KindEditor看樣子不錯
- Elasticsearch報Call to undefined xx makeAllSearchable()錯誤ElasticsearchUndefined
- [Djangorestframework]-富文字編輯器的使用DjangoRESTFramework
- CSDN編輯器的使用總結
- SSM使用UEditor富文字編輯器SSM
- [Flutter]開始使用:配置編輯器Flutter
- XHEditor編輯器的使用方法