看vuex案例时,头次看到这么个写法,很是不解
export function createMessage ({ text, thread }, cb) {
const timestamp = Date.now()
const id = 'm_' + timestamp
const message = {
id,
text,
timestamp,
threadID: thread.id,
threadName: thread.name,
authorName: 'Evan'
}
setTimeout(function () {
cb(message)
}, LATENCY)
}
想请教下这边的cb用法及含义
cb只是一个回调函数 seTimeout异步操作完成之后执行callback函数 这就像ajax请求一样 返回的res也是一个回调函数里面的参数