npm指定github地址和分支安装包:
1
| npm install git+https://github.com:LLK/scratch-blocks.git#local-closure
|
FAQs : error nunjucks@3.1.3: The engine “node” is incompatible with this module. Expected version “>= 6.9.0 <= 11.0.0-0”. Got “11.10.0”
解决方法:忽略引擎检查
1
| yarn install —ignore-engines
|
vc++构建环境 vsbuild
1 2 3
| https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=BuildTools&rr=https%3A%2F%2Fwww.jianshu.com%2Fp%2Fb4d739b43a23
npm install --global --production windows-build-tools
|
es6字符串拼接
1 2 3 4 5 6 7
| const welcome = 'You have logged in as ' + first + ' ' + last + '.' const db = 'http://' + host + ':' + port + '/' +
简写为:
const welcome = `You have logged in as ${first} ${last}`; const db = `http://${host}:${port}/${database}`;
|
sort排序数组对象(降序)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| var compare = function (prop) { return function (obj1, obj2) { var val1 = obj1[prop]; var val2 = obj2[prop];if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } else { return 0; } } }
arr.sort(compare("age"))
|
es6 find函数
1 2 3
| pet = pets.find(pet => pet.type ==='Dog' && pet.name === 'Tommy');
console.log(pet);
|
es6展开运算符
1 2
| const odd = [1,3,5] const nums = [2,4,6,...odd]
|
【js】:解构值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| const observable = require('mobx/observable'); const action = require('mobx/action'); const runInAction = require('mobx/runInAction'); const store = this.props.store; const form = this.props.form; const loading = this.props.loading; const errors = this.props.errors; const entity = this.props.entity;
import { observable, action, runInAction } from 'mobx'; const { store, form, loading, errors, entity } = this.props;
const { store, form, loading, errors, entity:contact } = this.props;
|
判断是否为null或者没有定义
1
| const variable2 = variable1 || 'new';
|
【npm】:升级node
1 2
| npm install -g n n stable
|
【npm】:升级npm
1 2
| npm install -g npm npm install npm@latest -g
|