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

如何使用VuePress搭建一個類型element ui文檔

 更新時間:2019年02月14日 11:39:41   作者:長是人千離  
這篇文章主要介紹了如何使用VuePress搭建一個類型element ui文檔,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

網(wǎng)站成果樣式

項目書寫步驟

github地址:https://github.com/xuhuihui/dataCom

官網(wǎng):http://caibaojian.com/vuepress/guide/getting-started.html

參考文章:http://www.fzitv.net/article/156259.htm

前言:我先git clone官方github,運行查看完整效果。 再根據(jù)官網(wǎng)介紹和參考文章,結(jié)合完整的代碼,自己一步步配置內(nèi)容。最后,參考element的設(shè)計樣式,修改并增加代碼,形成一個平臺組件庫的網(wǎng)站。

(1)在已有項目中安裝

# 安裝為本地依賴項
npm install -D vuepress

# 創(chuàng)建一個 docs 目錄
mkdir docs

# 創(chuàng)建一個 markdown 文件
echo '# Hello VuePress' > docs/README.md

# 給package.json 添加一些 scripts 腳本:{
 "scripts": {
  "docs:dev": "vuepress dev docs",
  "docs:build": "vuepress build docs"
 }
}# 運行項目
yarn run docs:dev 

出現(xiàn)顯示文檔亂碼問題,如圖所示:

解決方式:修改md文件編碼為UTF-8

改變md文件的內(nèi)容如下:

---
home: true
actionText: 前往 →
actionLink: /baseComponents/
features:
- title: 布局類組件
 details: 基本組件,為常用組件提供快速,可用的組件
- title: 可視化組件
 details: 積累將數(shù)據(jù)可視化的業(yè)務(wù)組件
- title: 知識庫
 details: 積累前端相關(guān)的知識,涵蓋 vue、react、koa2、nodejs 相關(guān)的知識點
---

(2)配置文件

配置(參考鏈接:http://caibaojian.com/vuepress/config/) VuePress 站點的基本文件是 .vuepress/config.js,其中導(dǎo)出一個 JavaScript 對象:

module.exports = {
 title: 'data Com', // 設(shè)置網(wǎng)站標(biāo)題
 description: 'Just for fun', //描述
 dest: './dist',  // 設(shè)置輸出目錄
 port: 2233, //端口
 themeConfig: { //主題配置
  // 添加導(dǎo)航欄
  nav: [
   { text: '主頁', link: '/' }, // 導(dǎo)航條
   { text: '組件文檔', link: '/baseComponents/' },
   { text: '知識庫', link: '/knowledge/' },
   { text: 'github',    // 這里是下拉列表展現(xiàn)形式。
    items: [
     { text: 'focus-outside', link: 'https://github.com/TaoXuSheng/focus-outside' },
     { text: 'stylus-converter', link: 'https://github.com/TaoXuSheng/stylus-converter' },
    ]
   }
  ],
  // 為以下路由添加側(cè)邊欄
  sidebar:{
   '/baseComponents/': [
    {
     title: '布局類組件',
     collapsable: true,
     children: [
      'base/test1',
      'base/test2',
      'base/test3',
      'base/test4',
     ]
    },
    {
     title: '可視化組件',
     collapsable: true,
     children: [
     ]
    },
    {
     title: '工具類組件',
     collapsable: true,
     children: [
     ]
    },
    {
     title: '方法類函數(shù)',
     collapsable: true,
     children: [
     ]
    }
   ],
   '/knowledge/': [
    {
     title: 'CSS知識庫',
     collapsable: false,
     children: [
     ]
    },
    {
     title: 'JS知識庫',
     collapsable: false,
     children: [
     ]
    },
    {
     title: 'node知識庫',
     collapsable: false,
     children: [
     ]
    },
    {
     title: 'vue知識庫',
     collapsable: false,
     children: [
     ]
    }
   ]
  }
 }
}

主題配置部分:在.vuepress/override.styl修改樣式:

$accentColor = #3EB9C8 // 主題色
$textColor = #2c3e50 // 文字顏色
$borderColor = #eaecef // 邊框顏色
$codeBgColor = #282c34 // 代碼背景顏色
// 代碼庫重置
.content pre{ margin: 0!important;}

(3)增加其它擴(kuò)展插件

插件npm安裝:element-ui,vue-echarts,vue-highlight。。

在.vuepress/enhanceApp.js引入:

/**
 * 擴(kuò)展 VuePress 應(yīng)用
 */
import VueHighlightJS from 'vue-highlight.js';
import 'highlight.js/styles/atom-one-dark.css';
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueECharts from 'vue-echarts' //注冊圖表

import './public/css/index.css' //組件css文件

export default ({
 Vue, // VuePress 正在使用的 Vue 構(gòu)造函數(shù)
 options, // 附加到根實例的一些選項
 router, // 當(dāng)前應(yīng)用的路由實例
 siteData // 站點元數(shù)據(jù)
}) => {
 // ...做一些其他的應(yīng)用級別的優(yōu)化
 Vue.use(VueHighlightJS)
 Vue.use(Element)
 Vue.component('chart', VueECharts)
}

(4)Markdown 拓展

調(diào)用別人寫好的輪子:https://www.npmjs.com/package/vue-highlight.js

 <highlight-code slot="codeText" lang="vue">
  <template>
   <div class="demo-button">
    <div>
     <dt-button>默認(rèn)按鈕</dt-button>
     <dt-button type="primary">主要按鈕</dt-button>
     <dt-button type="success">成功按鈕</dt-button>
     <dt-button type="info">信息按鈕</dt-button>
     <dt-button type="warning">警告按鈕</dt-button>
     <dt-button type="danger">危險按鈕</dt-button>
    </div>
  </template>
 </highlight-code>

(5)在Markdown 使用Vue-----插入按鈕樣式

#先寫一個按鈕組件.\vuepress\docs\.vuepress\components\src\button.vue

<template>
 <button
  class="dt-button"
  @click="handleClick"
  :disabled="disabled"
  :autofocus="autofocus"
  :type="nativeType"
  :class="[
   size ? 'dt-button--' + size : '',
   type ? 'dt-button--' + type : '',
   {
    'is-disabled': disabled,
    'is-round': round,
    'is-plain': plain
   }
  ]">
  <i :class="icon" v-if="icon"></i>
  <span v-if="$slots.default"><slot></slot></span>
 </button>
</template>

<script>
export default {
 name: 'DtButton',

 props: {
  size: String,
  type: {
   type: String,
   default: 'default'
  },
  nativeType: {
   type: String,
   default: 'button'
  },
  disabled: Boolean,
  round: Boolean,
  plain: Boolean,
  autofocus: Boolean,
  icon: {
   type: String,
   default: ''
  }
 },
 methods: {
  handleClick (event) {
   this.$emit('click', event)
  }
 },
 mounted () {
  this.$emit('click', event)
 }
}
</script>

#css樣式,在.\vuepress\docs\.vuepress\public\css\button.css,寫法參考餓了么。

#在.\study\vuepress\docs\.vuepress\public\css\index.css匯總

@import './iconfont.css';
@import './icon.css';

@import './card.css';
@import './button.css'; //按鈕組件
@import './checkbox.css';

#在.\vuepress\docs\.vuepress\components\test\test1.vue文件夾下面調(diào)用button

<template>
 <div class="demo-button">
  <div>
   <dt-button>默認(rèn)按鈕</dt-button>
   <dt-button type="primary">主要按鈕</dt-button>
   <dt-button type="success">成功按鈕</dt-button>
   <dt-button type="info">信息按鈕</dt-button>
   <dt-button type="warning">警告按鈕</dt-button>
   <dt-button type="danger">危險按鈕</dt-button>
  </div>
 </div>
</template>

<script>
import DtButton from '../src/button'
export default {
 name: 'buttonWrap',
 components: {
  DtButton
 }
}
</script>

<style lang="less" scoped>
.demo-button{
 width: 100%;
 text-align: center;
 div {
  margin: 10px 0;
 }
}
</style>

#vuepress會自動根據(jù)路徑注冊組件,我們只要映射文件路徑,就可以調(diào)用組件。

在.\vuepress\docs\baseComponents\base\test1.md

# 測試案例1
---
<Common-Democode title="基本用法" description="基本按鈕用法">
 <test-test1></test-test1>
 <highlight-code slot="codeText" lang="vue">
  <template>
   <div class="demo-button">
    <div>
     <dt-button>默認(rèn)按鈕</dt-button>
     <dt-button type="primary">主要按鈕</dt-button>
     <dt-button type="success">成功按鈕</dt-button>
     <dt-button type="info">信息按鈕</dt-button>
     <dt-button type="warning">警告按鈕</dt-button>
     <dt-button type="danger">危險按鈕</dt-button>
    </div>
   </div>
  </template>
 </highlight-code>
</Common-Democode>

| Tables    | Are      | Cool |
| ------------- |:-------------:| -----:|
| col 3 is   | right-aligned | $1600 |
| col 2 is   | centered   |  $12 |
| zebra stripes | are neat   |  $1 |

#展示效果如圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue router傳遞參數(shù)并解決刷新頁面參數(shù)丟失問題

    Vue router傳遞參數(shù)并解決刷新頁面參數(shù)丟失問題

    這篇文章主要介紹了Vue router傳遞參數(shù)并解決刷新頁面參數(shù)丟失問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Vue實現(xiàn)開始時間和結(jié)束時間范圍查詢

    Vue實現(xiàn)開始時間和結(jié)束時間范圍查詢

    這篇文章主要為大家詳細(xì)介紹了Vue實現(xiàn)開始時間和結(jié)束時間的范圍查詢,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Vuejs實現(xiàn)帶樣式的單文件組件新方法

    Vuejs實現(xiàn)帶樣式的單文件組件新方法

    這篇文章主要為大家詳細(xì)為大家詳細(xì)介紹了Vuejs實現(xiàn)帶樣式的單文件組件的新方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • vue-cli 如何打包上線的方法示例

    vue-cli 如何打包上線的方法示例

    這篇文章主要介紹了vue-cli 如何打包上線的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • Vue2.2.0+新特性整理及注意事項

    Vue2.2.0+新特性整理及注意事項

    本文是小編精心給大家收藏整理的關(guān)于Vue2.2.0+新特性,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-08-08
  • 富文本編輯器vue2-editor實現(xiàn)全屏功能

    富文本編輯器vue2-editor實現(xiàn)全屏功能

    這篇文章主要介紹了富文本編輯器vue2-editor實現(xiàn)全屏功能,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2019-05-05
  • vite與xcode環(huán)境變量配置記錄詳解

    vite與xcode環(huán)境變量配置記錄詳解

    這篇文章主要為大家介紹了vite與xcode環(huán)境變量配置記錄詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • VUE3使用JSON編輯器的詳細(xì)圖文教程

    VUE3使用JSON編輯器的詳細(xì)圖文教程

    最近項目中有用到j(luò)son編輯器,我選用了這款vue的編輯器,看起來也是比較簡潔,接下來就具體介紹一下它,下面這篇文章主要給大家介紹了關(guān)于VUE3使用JSON編輯器的詳細(xì)圖文教程,需要的朋友可以參考下
    2023-04-04
  • Vue +WebSocket + WaveSurferJS 實現(xiàn)H5聊天對話交互的實例

    Vue +WebSocket + WaveSurferJS 實現(xiàn)H5聊天對話交互的實例

    這篇文章主要介紹了Vue +WebSocket + WaveSurferJS 實現(xiàn)H5聊天對話交互的實例,幫助大家更好的理解和學(xué)習(xí)vue,感興趣的朋友可以了解下
    2020-11-11
  • 關(guān)于element Drawer抽屜的使用

    關(guān)于element Drawer抽屜的使用

    這篇文章主要介紹了關(guān)于element Drawer抽屜的使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-07-07

最新評論

东城区| 西林县| 武威市| 南康市| 阜新| 蛟河市| 云和县| 常山县| 武城县| 田阳县| 黄梅县| 扎鲁特旗| 上栗县| 哈巴河县| 阳城县| 庆元县| 耿马| 滨海县| 黑河市| 郸城县| 南昌市| 富锦市| 盐山县| 微博| 湘潭县| 永吉县| 闽清县| 五华县| 额尔古纳市| 都安| 关岭| 瓦房店市| 贵州省| 定西市| 疏勒县| 波密县| 双桥区| 宜阳县| 邢台市| 榆社县| 苍南县|