日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

【操作】vue-markdown使用

發布時間:2024/9/30 vue 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【操作】vue-markdown使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

導包

npm 安裝

npm install --save vue-markdown

引入github-markdown-css

npm 安裝

npm install github-markdown-css

導入github-markdown.css文件

import 'github-markdown-css/github-markdown.css

并設置markdoen-body樣式

.markdown-body {box-sizing: border-box;min-width: 200px;max-width: 980px;margin: 0 auto;padding: 45px; }@media (max-width: 767px) {.markdown-body {padding: 15px;} }

感謝作者:github: https://github.com/sindresorhus/github-markdown-css

完整代碼寫法

<!--* @Description: 渲染markdown文件--> <template><div id="my-markdown" class="markdown-body"><vue-markdown :source="md"></vue-markdown></div> </template> <script> import VueMarkdown from "vue-markdown"; export default {name: "MyMarkdown",components: {VueMarkdown},data() {return {md: ""};},created() {// 從后端請求README.mdthis.$axios.get("/api/public/docs/README.md", {}).then(res => {this.md = res.data.data;}).catch(err => {return Promise.reject(err);});} }; </script> <style> @import 'github-markdown-css/github-markdown.css'; .markdown-body {box-sizing: border-box;margin: 0 auto;padding: 0 40px; } </style>

后端接口

@RequestMapping("/api/public/docs/README.md")public ResT getAbout() throws IOException {String readme = "README.md";//1.獲取通道FileInputStream fin = new FileInputStream(readme);FileChannel fc = fin.getChannel();//2.創建緩沖區ByteBuffer buffer = ByteBuffer.allocate(1024);int length = -1;StringBuffer stringBuffer = new StringBuffer();//3.將數據從通道讀到緩沖區中while ((length = fc.read(buffer)) != -1) {stringBuffer.append(new String(buffer.array()));buffer.clear();}fin.close();return ResT.ok().setData(stringBuffer.toString().trim());}

截圖

總結

以上是生活随笔為你收集整理的【操作】vue-markdown使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。