前言
在項(xiàng)目中,往往需要使用自定義注釋模板,通過(guò)快捷鍵為函數(shù)添加注釋,使其有更好的可讀性。Hbuilderx編譯器自定義注釋模板的設(shè)置如下。
進(jìn)入編輯器后--工具--代碼塊設(shè)置--javascript代碼塊

hbuilder0.png
在打開(kāi)的JavaScript.json右側(cè)添加如下代碼(右側(cè)有代碼的話,直接刪除替換)
{
"file-annotation": {
"prefix": "anno",
"body": [
"/**",
" * @Description:",
" * ",
" * @author",
" * ",
" * @param $1",
" * @return $2",
" * ",
" * @createTime: $DATE_TIME",
" * @Copyright by 天津津湖數(shù)據(jù)有限公司",
" */"
],
"triggerAssist": false,
"description": "file annotation"
},
"method-annotation": {
"prefix": "anno",
"body": [
"/**",
" * @Description:",
" * ",
" * @author",
" * ",
" * @param $1",
" * @return $2",
" * ",
" * @createTime: $DATE_TIME",
" * @Copyright by 天津津湖數(shù)據(jù)有限公司",
" */"
],
"triggerAssist": false,
"description": "file annotation"
}
}
注:prefix對(duì)應(yīng)的值為代碼塊的快捷鍵,筆者設(shè)置的anno,可以自行選用其他的字符串。

hbuilder2.png
代碼塊使用
在vue或js文件里輸入快捷字符串a(chǎn)nno(根據(jù)自己設(shè)置的字符串輸入),點(diǎn)擊回車,效果如下:

hbuilder3.png