代码之家  ›  专栏  ›  技术社区  ›  Eduardo

Vuejs-对导出类使用函数getProperties

  •  0
  • Eduardo  · 技术社区  · 7 年前

    我有一个源模块:

    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())
    

    但它不起作用,什么是获得这种方法的正确途径?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Mahdi Aryayi    7 年前

    您正在导出 function 但你用它就像 Object !

    似乎您必须这样使用它(调用函数):

    import myProperties from '../../sources/properties'
    console.log(myProperties().getProperties())