欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue3中ace-editor的簡(jiǎn)單使用方法實(shí)例

 更新時(shí)間:2023年10月23日 11:10:27   作者:youhebuke225  
這篇文章主要給大家介紹了關(guān)于vue3中ace-editor簡(jiǎn)單使用的相關(guān)資料,ace-editor是一種代碼編輯器,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下

簡(jiǎn)介

安裝

首先我們下載編輯器,當(dāng)然我們也可以使用npm進(jìn)行下載

yarn add vue3-ace-editor

我們?cè)趘ue3中寫(xiě)上如下代碼

<script setup lang="ts">
import { ref } from "vue";
import { VAceEditor } from "vue3-ace-editor"

const content = ref("<div>Hello World</div>")
</script>

<template>
    <v-ace-editor v-model:value="content" lang="html" theme="github" style="height: 300px" />
</template>

這個(gè)時(shí)候代碼編輯器就顯示出來(lái)了

深入

但是我們會(huì)發(fā)現(xiàn)這時(shí)候主題和高亮似乎沒(méi)有生效,編輯器的主題也沒(méi)有生效

這個(gè)時(shí)候我們新建一個(gè)文件ace.config.ts,寫(xiě)上如下代碼

import ace from 'ace-builds';

import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url';
ace.config.setModuleUrl('ace/mode/json', modeJsonUrl);

import modeJavascriptUrl from 'ace-builds/src-noconflict/mode-javascript?url';
ace.config.setModuleUrl('ace/mode/javascript', modeJavascriptUrl);

import modeHtmlUrl from 'ace-builds/src-noconflict/mode-html?url';
ace.config.setModuleUrl('ace/mode/html', modeHtmlUrl);

import modeYamlUrl from 'ace-builds/src-noconflict/mode-yaml?url';
ace.config.setModuleUrl('ace/mode/yaml', modeYamlUrl);

import themeGithubUrl from 'ace-builds/src-noconflict/theme-github?url';
ace.config.setModuleUrl('ace/theme/github', themeGithubUrl);

import themeChromeUrl from 'ace-builds/src-noconflict/theme-chrome?url';
ace.config.setModuleUrl('ace/theme/chrome', themeChromeUrl);

import themeMonokaiUrl from 'ace-builds/src-noconflict/theme-monokai?url';
ace.config.setModuleUrl('ace/theme/monokai', themeMonokaiUrl);

import workerBaseUrl from 'ace-builds/src-noconflict/worker-base?url';
ace.config.setModuleUrl('ace/mode/base', workerBaseUrl);

import workerJsonUrl from 'ace-builds/src-noconflict/worker-json?url';
ace.config.setModuleUrl('ace/mode/json_worker', workerJsonUrl);

import workerJavascriptUrl from 'ace-builds/src-noconflict/worker-javascript?url';
ace.config.setModuleUrl('ace/mode/javascript_worker', workerJavascriptUrl);

import workerHtmlUrl from 'ace-builds/src-noconflict/worker-html?url';
ace.config.setModuleUrl('ace/mode/html_worker', workerHtmlUrl);

import workerYamlUrl from 'ace-builds/src-noconflict/worker-yaml?url';
ace.config.setModuleUrl('ace/mode/yaml_worker', workerYamlUrl);

import snippetsHtmlUrl from 'ace-builds/src-noconflict/snippets/html?url';
ace.config.setModuleUrl('ace/snippets/html', snippetsHtmlUrl);

import snippetsJsUrl from 'ace-builds/src-noconflict/snippets/javascript?url';
ace.config.setModuleUrl('ace/snippets/javascript', snippetsJsUrl);

import snippetsYamlUrl from 'ace-builds/src-noconflict/snippets/yaml?url';
ace.config.setModuleUrl('ace/snippets/javascript', snippetsYamlUrl);

import snippetsJsonUrl from 'ace-builds/src-noconflict/snippets/json?url';
ace.config.setModuleUrl('ace/snippets/json', snippetsJsonUrl);

import 'ace-builds/src-noconflict/ext-language_tools';
ace.require("ace/ext/language_tools");

寫(xiě)完之后,我們?cè)谑褂玫牡胤揭胍幌庐?dāng)前的配置文件便可

import '../../ace.config';

總結(jié)

到此這篇關(guān)于vue3中ace-editor的簡(jiǎn)單使用的文章就介紹到這了,更多相關(guān)vue3中ace-editor使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:

相關(guān)文章

  • vue文件運(yùn)行的方法教學(xué)

    vue文件運(yùn)行的方法教學(xué)

    在本篇文章里小編給大家分享了關(guān)于vue文件運(yùn)行的方法教學(xué)內(nèi)容,有需要的朋友們跟著學(xué)習(xí)下。
    2019-02-02
  • 一文詳解Vue3中如何使用Vue?Router

    一文詳解Vue3中如何使用Vue?Router

    Vue-Router路由是根據(jù)不同的url地址展現(xiàn)不同的內(nèi)容或頁(yè)面,這篇文章主要給大家介紹了關(guān)于Vue3中如何使用Vue?Router的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-02-02
  • 詳解如何使用vue實(shí)現(xiàn)頁(yè)面訪(fǎng)問(wèn)攔截

    詳解如何使用vue實(shí)現(xiàn)頁(yè)面訪(fǎng)問(wèn)攔截

    這篇文章主要為大家詳細(xì)介紹了如何使用vue實(shí)現(xiàn)頁(yè)面訪(fǎng)問(wèn)攔截功能,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,需要的可以了解一下
    2023-08-08
  • vue項(xiàng)目使用高德地圖時(shí)報(bào)錯(cuò):AMap?is?not?defined解決辦法

    vue項(xiàng)目使用高德地圖時(shí)報(bào)錯(cuò):AMap?is?not?defined解決辦法

    這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目使用高德地圖時(shí)報(bào)錯(cuò):AMap?is?not?defined的解決辦法,"AMap is not defined"是一個(gè)錯(cuò)誤提示,意思是在代碼中沒(méi)有找到定義的AMap,需要的朋友可以參考下
    2023-12-12
  • vue實(shí)現(xiàn)評(píng)論列表

    vue實(shí)現(xiàn)評(píng)論列表

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)評(píng)論列表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • 如何解決ElementPlus的el-table底白線(xiàn)問(wèn)題

    如何解決ElementPlus的el-table底白線(xiàn)問(wèn)題

    這篇文章主要介紹了如何解決ElementPlus的el-table底白線(xiàn)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Vue.js之VNode的使用

    Vue.js之VNode的使用

    這篇文章主要介紹了Vue.js之VNode的使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • vue實(shí)現(xiàn)標(biāo)簽云效果的示例

    vue實(shí)現(xiàn)標(biāo)簽云效果的示例

    這篇文章主要介紹了vue實(shí)現(xiàn)標(biāo)簽云效果的示例,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下
    2020-11-11
  • element-ui中按需引入的實(shí)現(xiàn)

    element-ui中按需引入的實(shí)現(xiàn)

    這篇文章主要介紹了element-ui中按需引入的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • vue使用echarts詞云圖的實(shí)戰(zhàn)記錄

    vue使用echarts詞云圖的實(shí)戰(zhàn)記錄

    這篇文章主要給大家介紹了關(guān)于vue使用echarts詞云圖的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-05-05

最新評(píng)論