require('xx').default
加default
的原因,链接
import require
区别
import
静态编译,require
不是。
const url = 'xxxx' + 'yyyy'
import url
,报错。require(url)
不报错。动态加载使用require
。
process.env.NODE_ENV
process
是全局变量,提供node
的有关信息,env
是它的属性。
输入node
,再输入process.env
即可打印。
NODE_ENV
不是对象原有属性,是添加上去的环境变量。
dayjs
格式时间的插件,2kb,支持所有的浏览器
dayjs文档
d2admin
页面发请求过程
mock
拦截请求,模拟数据的过程
actionFn({commit, dispatch}, {xx: xx, yy: yy} = {}, {root: true})
参数
第二个参数是为了初始化值为空,并且运行之初不报错
mixins
作用
hasOwnProperty
判断对象有没有这个属性,返回布尔值
const object1 = new Object();
object1.property1 = 42;
console.log(object1.hasOwnProperty('property1'));
// expected output: true
console.log(object1.hasOwnProperty('toString'));
// expected output: false
在不继承的情况下迭代
var o = {
a: 'aa',
b: 'bb',
c: {
c1: '11',
c2: '22'
}
}
let newO = {}
for (const n in o) {
if(o.hasOwnProperty(n)) {
newO[n] = o[n]
}
}
console.log(newO)
lowdb
lowdb
github地址
Small JSON database for Node, Electron and the browser
数据保存在db.json
或者LocalStorage
里的