参数带有大括号是什么意思
发布于 9 年前 作者 MyNodeJs 5096 次预览 最后一次回复是 9 年前 来自 问答
{ data ({ to }) { return store.fetchItem(to.params.id).then(item => { document.title = item.title + ’ | Vue.js HN Clone’ return { item, // the final resolved data can further contain Promises comments: store.fetchItems(item.kids), pollOptions: item.type === ‘poll’ ? store.fetchItems(item.parts) : null } }) } } 那个to是什么意思?去掉大括号不行吗?
3 回复
参见ES6解构赋值
{ to }相当于{ to: to },语法糖而已不知道