最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue2.0使用md-edit編輯器的過程

 更新時(shí)間:2024年02月06日 10:49:17   作者:源碼plus  
這篇文章主要介紹了vue2.0+使用md-edit編輯器的解決方案,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

前言:小劉開發(fā)過程中,如果是博客項(xiàng)目一般是會(huì)用到富文本。眾多富文本中,小劉選擇了markdown,并記錄分享了下來。

 # 使用 npm
npm i @kangc/v-md-editor -S
main.js基本配置
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
import Prism from 'prismjs';
VueMarkdownEditor.use(vuepressTheme, {
  Prism,
});
/* 2、v-md-editor 代碼塊關(guān)鍵字高亮  */
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js';
import '@kangc/v-md-editor/lib/theme/style/github.css';
// 引入所有語言包
import hljs from 'highlight.js';
VueMarkdownEditor.use(githubTheme, {
  Hljs: hljs,
});
/**
 * 3.創(chuàng)建行號
 */
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';
VueMarkdownEditor.use(createLineNumbertPlugin());
Vue.use(VueMarkdownEditor);

頁面加載使用

<template>
  <div class="hello">
        <v-md-editor v-model="text" height="400px"></v-md-editor>
  </div>
</template>
 <script>
export default {
  data() {
    return {
      text: '',
    };
  },
};
</script>

特別注意:當(dāng)步驟到行號的時(shí)候,會(huì)出現(xiàn)依賴有問題;
類似:* @babel/runtime/helpers/interopRequireDefault in ./node_modules/@kangc/v-md-editor/lib/plugins/line-number/index.js To install it, you can run: npm install --save @babel/runtime/helpers/interopRequireDefault Error from chokidar (C:): Error: EBUSY: reso。。。。。。。
這種錯(cuò)誤;

解決方案:

當(dāng)使用 babel 轉(zhuǎn)換 es 6出現(xiàn)下面錯(cuò)誤時(shí):

Module not found: Error: Can’t resolve
‘@babel/runtime/helpers/interopRequireDefault’ 我們可以重新安裝一下:

npm i @babel/runtime --save-dev

至此:github主題的markdown編輯器基本用法完成了。

運(yùn)行demo效果:

圖片上傳功能:將圖片上傳到服務(wù)器,然后回顯圖片

:disabled-menus="[]"
@upload-image="handleUploadImage"

注意

上傳圖片菜單默認(rèn)為禁用狀態(tài) 設(shè)置 disabled-menus 為空數(shù)組可以開啟。

 handleUploadImage(event, insertImage, files) {
      // 拿到 files 之后上傳到文件服務(wù)器,然后向編輯框中插入對應(yīng)的內(nèi)容
      console.log(files);
      // 此處只做示例
      insertImage({
        url:
          'https://pic.rmb.bdstatic.com/bjh/down/a477f2b15e2039b9fc7e2282791a9897.jpeg',
        desc: '七龍珠',
        // width: 'auto',
        // height: 'auto',
      });
    },

測試效果如下

到此這篇關(guān)于vue2.0+使用md-edit編輯器的文章就介紹到這了,更多相關(guān)vue2.0使用md-edit編輯器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

大余县| 孝义市| 永福县| 宁国市| 工布江达县| 同江市| 建阳市| 宜黄县| 雷州市| 石楼县| 靖宇县| 加查县| 图们市| 凌海市| 武清区| 怀安县| 兰坪| 四子王旗| 淮南市| 无极县| 于田县| 沙坪坝区| 苍梧县| 应城市| 磐石市| 页游| 阿坝县| 大悟县| 房产| 洛川县| 陆川县| 永和县| 和静县| 盐亭县| 太康县| 集安市| 稷山县| 儋州市| 翼城县| 陆丰市| 蓝田县|