vue3-ace-editor如何配置語法
vue3-ace-editor配置語法
<template>
<v-ace-editor
v-model:value="sqlContent"
@init="editorInit"
lang="javascript"
:options="{
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
fontSize: 14,
tabSize: 2,
showPrintMargin: false,
highlightActiveLine: true,
}"
theme="monokai"
style="height: 400px; width: 400px; background: #000; color: #fff"
>
</v-ace-editor>
</template><script>
import {
defineComponent,
reactive,
toRefs,
ref,
onMounted,
nextTick,
} from "vue";
import * as ace from 'ace-builds';
ace.config.set('basePath', '/static/src-min-noconflict/');
import { VAceEditor } from "vue3-ace-editor";
export default defineComponent({
name: "page-three",
components: {
VAceEditor,
},
setup() {
const sqlContent = ref("");
const state = reactive({
test: "",
});
function editorInit() {
require("ace-builds/src-noconflict/ext-language_tools");
require("ace-builds/src-noconflict/snippets/sql");
require("ace-builds/src-noconflict/mode-sql");
require("ace-builds/src-noconflict/theme-monokai");
require("ace-builds/src-noconflict/mode-html");
require("ace-builds/src-noconflict/mode-html_elixir");
require("ace-builds/src-noconflict/mode-html_ruby");
require("ace-builds/src-noconflict/mode-javascript");
require("ace-builds/src-noconflict/mode-python");
require("ace-builds/src-noconflict/snippets/less");
require("ace-builds/src-noconflict/theme-chrome");
require("ace-builds/src-noconflict/ext-static_highlight");
require("ace-builds/src-noconflict/ext-beautify");
}
onMounted(() => {
nextTick(() => {
editorInit;
});
});
return {
sqlContent,
...toRefs(state),
editorInit,
};
},
});
</script><style>
/* 修改光標(biāo)顏色 */
.ace_cursor {
color: #fff !important;
}
</style>vue3-ace-editor報(bào)Failed to execute ‘importScripts‘ on ‘WorkerGlobalScope‘錯(cuò)誤處理
因?yàn)轫?xiàng)目需要引入vue3-ace-editor編輯器,下面是引入后的設(shè)置

引入后發(fā)現(xiàn)每個(gè)只要用到ace-editor的組件就報(bào)
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://172.16.38.100:3000/worker-javascript.js' failed to load.
如下:

本以為應(yīng)該百度都有解決方案,所以也不在意,結(jié)果發(fā)現(xiàn)百度出來的試過都不對,先叫相關(guān)同事解決說可能是引入js的方式有問題,他沒空后我試了一下 也不是。
得到了正確的答案,為了不翻就能找到答案,特意寫篇博客

我在項(xiàng)目里面就是這樣的

看了一下文檔,這個(gè)設(shè)置為ture主要是用于檢查語法,具體看下圖:

ok,按上面的操作就不報(bào)錯(cuò)啦。搞定,nice!
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue中多個(gè)倒計(jì)時(shí)實(shí)現(xiàn)代碼實(shí)例
這篇文章主要介紹了vue中多個(gè)倒計(jì)時(shí)實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
Vue中v-show添加表達(dá)式的問題(判斷是否顯示)
這篇文章主要介紹了關(guān)于Vue中v-show中添加表達(dá)式用于判斷是否顯示的問題,很多朋友經(jīng)常會(huì)遇到這樣的需求,有數(shù)據(jù)來源和標(biāo)簽類型兩行選項(xiàng),需要實(shí)現(xiàn)點(diǎn)擊上面的某個(gè)數(shù)據(jù)來源時(shí),標(biāo)簽類型自動(dòng)切換功能,感興趣的朋友一起看看吧2018-03-03
在vue中通過render函數(shù)給子組件設(shè)置ref操作
這篇文章主要介紹了在vue中通過render函數(shù)給子組件設(shè)置ref操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11
Vue3實(shí)現(xiàn)微信支付寶PC端支付的步驟(附實(shí)例代碼)
因?yàn)楣卷?xiàng)目涉及到充值功能所以做了支付寶、微信的支付功能,這篇文章主要介紹了Vue3實(shí)現(xiàn)微信支付寶PC端支付的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-09-09
解決vue項(xiàng)目中某一頁面不想引用公共組件app.vue的問題
這篇文章主要介紹了解決vue項(xiàng)目中某一頁面不想引用公共組件app.vue的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
vue-cli項(xiàng)目使用mock數(shù)據(jù)的方法(借助express)
現(xiàn)如今前后端分離開發(fā)越來越普遍,前端人員寫好頁面后可以自己模擬一些數(shù)據(jù)進(jìn)行代碼測試,這樣就不必等后端接口,提高了我們開發(fā)效率。今天就來分析下前端常用的mock數(shù)據(jù)的方式是如何實(shí)現(xiàn)的,需要的朋友可以參考下2019-04-04

