将Typescript服务注入javascript .vue组件

时间:2018-06-23 17:49:07

标签: typescript vue.js

我有2条路径,FlowService可以管理这2条路径。

这是打字稿界面:

export interface FlowInterface {

  //First effect
  goToResultPreview: () => void

  //Second effect
  goToResult: () => void
}

这是第一个服务:

import {FlowInterface} from "./FlowInterface";

class CreditabilityFlow implements FlowInterface{
  goToResultPreview: () => void = ()=> {
    console.log('CreditabilityFlow - goToResultPreview')
  }

  goToResult: () => void = () => {
    console.log('CreditabilityFlow - goToResult')
  }

}

export default new CreditabilityFlow()

这是第二项服务:

class InstallmentFlow implements FlowInterface{
  goToResultPreview: () => void = ()=> {
    console.log('InstallmentFlow - goToResultPreview')
  }

  goToResult: () => void = () => {
    console.log('InstallmentFlow - goToResult')
  }
}

两者都实现相同的接口。所以现在我也有2个用JavaScript编写的.vue组件。是否可以导入可以导入的FlowService之类的东西,并在InstallmentFlow返回的第一视图集CreditabilityFlowFlowService中的某处?

0 个答案:

没有答案