維護代碼 重要的是有檔案,js-doc 在線生成檔案 是一個很好的選擇
依賴
“vue-template-compiler”: “^2.6.11”,
“minami”: “^1.2.3”,
js-doc 6.9.0
根目錄下創建 .jsdoc.conf.json
內容
{
"tags": {
"allowUnknownTags": true,
// 指定所用詞典
"dictionaries": [
"jsdoc"
]
},
// 查找檔案的深度 需要用 -r 引數
"recurseDepth": 10,
"source": {
"include": [
// 需要編譯的檔案路徑 使用時請替換
"./src/index/packages"
],
"includePattern": ".+\\.(vue)$",
"excludePattern": "(^|\\/|\\\\)_"
},
// 使用插件
"plugins": [
// 插件路徑
"./jsdoc-vue"
],
"templates": {
"cleverLinks": false,
"monospaceLinks": true,
"useLongnameInNav": false,
"showInheritedInNav": true
},
"opts": {
// 檔案輸出路徑
"destination": "./src/index/doc",
"encoding": "utf8",
"private": true,
"recurse": true,
// 使用模板 minami
"template": "./node_modules/minami"
}
}
注意創建doc 檔案目錄
根目錄創建 jsdoc-vue.js
var compiler = require("vue-template-compiler");
exports.handlers = {
// 利用 vue-template-compiler 編譯 vue 模板
beforeParse: function(e) {
if (/\.vue$/.test(e.filename)) {
var output = compiler.parseComponent(e.source);
e.source = output.script ? output.script.content : "";
}
}
};
package.json
命令 npm run doc
"doc": "jsdoc -r -c .jsdoc.conf.json"
如果你在運行時 遇到這個提示 Vue packages version mismatch 不要慌 這是vue-template-compiler 與 vue 版本不一致導致 只需要更新 npm install vue-template-compiler@version 指定版本就可以了, 指定的版本在報錯中有指出
大功告成!!!

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/242921.html
標籤:區塊鏈
上一篇:拖拽
下一篇:ETH的挖礦原理與機制
