在浏览 VueJS 资源时,我遇到了 this piece :
const injectedComp = {
inject: ['foo', 'bar'],
render () {},
created () {
injected = [this.foo, this.bar]
}
}
我的问题是 - 什么是 render ()
和 created ()
- 函数调用?定义?还有什么?那里到底发生了什么?
最佳答案
render
和created
都是具有函数值的injectedComp
对象的属性。语法适用于 method shorthand是相当新的,由 ES2015 规范引入。你可以这样想你的例子:
const injectedComp = {
inject: ['foo', 'bar'],
render: function render() {},
created: function created() {
injected = [this.foo, this.bar]
}
}
关于javascript - 对象范围内的函数调用或定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46095795/