[英]Vuejs - use function getProperties on exported class
I have a source module: 我有一个源模块:
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([{}]))
}
}
}
I need to access it from another section so I am importing it: 我需要从另一部分访问它,所以我将其导入:
import myProperties from '../../sources/properties'
Then I try: 然后我尝试:
console.log(myProperties.getProperties())
but it does not work, what is the proper way to get access to this method? 但它不起作用,访问此方法的正确方法是什么?
You are exporting a function
BUT you are using it like an Object
! 您正在导出function
但您像Object
一样使用它!
It seems that you have to use it like this (calling the function): 看来您必须像这样使用它(调用函数):
import myProperties from '../../sources/properties'
console.log(myProperties().getProperties())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.