前言
在项目中,往往需要使用自定义注释模板,通过快捷键为函数添加注释,使其有更好的可读性。Hbuilderx编译器自定义注释模板的设置如下。
进入编辑器后--工具--代码块设置--javascript代码块

hbuilder0.png
在打开的JavaScript.json右侧添加如下代码(右侧有代码的话,直接删除替换)
{
"file-annotation": {
"prefix": "anno",
"body": [
"/**",
" * @Description:",
" * ",
" * @author",
" * ",
" * @param $1",
" * @return $2",
" * ",
" * @createTime: $DATE_TIME",
" * @Copyright by 天津津湖数据有限公司",
" */"
],
"triggerAssist": false,
"description": "file annotation"
},
"method-annotation": {
"prefix": "anno",
"body": [
"/**",
" * @Description:",
" * ",
" * @author",
" * ",
" * @param $1",
" * @return $2",
" * ",
" * @createTime: $DATE_TIME",
" * @Copyright by 天津津湖数据有限公司",
" */"
],
"triggerAssist": false,
"description": "file annotation"
}
}
注:prefix对应的值为代码块的快捷键,笔者设置的anno,可以自行选用其他的字符串。

hbuilder2.png
代码块使用
在vue或js文件里输入快捷字符串anno(根据自己设置的字符串输入),点击回车,效果如下:

hbuilder3.png