Javascript Vuejs-在导出的类上使用函数getProperties
我有一个源模块:Javascript Vuejs-在导出的类上使用函数getProperties,javascript,ecmascript-6,vuejs2,Javascript,Ecmascript 6,Vuejs2,我有一个源模块: import _ from 'underscore' import {Observable} from 'rxjs' export default function (rxfb) { return { getProperties () { return rxfb.sources.user.getUser() .switchMap(({properties}) => properties
import _ from 'underscore'
import {Observable} from 'rxjs'
export default function (rxfb) {
return {
getProperties () {
return rxfb.sources.user.getUser()
.switchMap(({properties}) =>
properties
? Observable.combineLatest(_(properties).map((property, propertyId) =>
this.getProperty(propertyId).map(property => ({propertyId, ...property}))))
: Observable.from([{}]))
}
}
}
我需要从另一个部分访问它,因此我要导入它:
import myProperties from '../../sources/properties'
然后我尝试:
console.log(myProperties.getProperties())
但是它不起作用,访问此方法的正确方法是什么?您正在导出一个
函数
,但您将其用作对象
似乎您必须这样使用它(调用函数):
你能准确地告诉我你得到的GetProperties不是一个函数的错误吗?请参考:我发布了答案,如果有任何问题,请告诉我。
import myProperties from '../../sources/properties'
console.log(myProperties().getProperties())