自我实践
并发
使用了Async/Await good
变量
使用有意义并且可读的变量名称 ok
为相同类型的变量使用相同的词汇 ok 风格考虑统一动词名词前?
使用可搜索的名称 ok
使用解释性的变量 bad 一些操作序号 可以定义成一个有解释性的常量
避免心理映射 ok
不添加不必要的上下文 ok
使用默认变量替代短路运算或条件 ok
今后继续注意变量的提高

其他风格可以参见下面文章

参考文章
https://segmentfault.com/a/1190000008039771
https://github.com/beginor/clean-code-javascripthttps://github.com/beginor/clean-code-javascript

vscode+eslint自动格式化vue代码的方法
{ "eslint.options": { "extensions": [ ".js", ".vue" ] }, "eslint.validate": [ "javascript", { "language": "vue", "autoFix": true }, "html", "vue" ], "eslint.autoFixOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "eslint.codeAction.disableRuleComment": {}, "eslint.alwaysShowStatus": true, }

https://www.cnblogs.com/jichi/p/12891881.html

变量命名风格

https://www.cnblogs.com/dolphin0520/p/10639167.html

前端获取后台数据逻辑

以获取table列表为例子

try {
const res = await this.getList()
const {total, data, errmsg} = res
if(total != undefined, data != undefined) {
  // do something
} else if(errmsg) {
  this.$message(errmsg)
}
}catch (e) {
  console.log(e)
  this.$message('getList failed')
}

嵌套解构赋值

const user = {
  id: 123,
  name: 'hehe'
};

const {
    education: {
        degree
    } = {}
} = user;
console.log(degree); //prints: undefined

参照

https://segmentfault.com/a/1190000012280806

let node = {
    name: 'mike',
    age: 25
};
name = 'lily';
age = 20;
console.log(name); // lily
console.log(age);//20
({name, age} = node);
console.log(name);//mike
console.log(age);//25

以上代码的逻辑为:预先定义的变量name和age分别被初始化为'lily'和20之后,又用node对象的属性,重新赋值给name和age变量。解构赋值的语法要求,一定要用一对小括号()包裹整个解构赋值表达式。
参照

https://segmentfault.com/a/1190000019923707