小编Ale*_*íaz的帖子

将 javascript es6 类转换为函数式编程风格

我有一个用reactjs编写的类,但想使用函数式编程而不是OOP转换为函数。有人告诉我怎么做吗?跟着我的课。

import * as h from './hydraulic';

export default class verticalfloculator_diag {
  constructor (width, length, depth, npantalla, espaciamiento, espesor, pasos) {
    this.detention_time = 0;
    this.ancho = width
    this.largo = length
    this.profundidad = depth
    this.npantalla = npantalla
    this.espaciamiento_pantallas = espaciamiento
    this.espesor_pantallas = espesor
    this.alto_pasos = pasos
    this.area_entrepantallas = this.espaciamiento_pantallas * this.ancho
    this.volumen = this.ancho * this.profundidad * this.largo
    this.radiohidraulico = h.radio_hydraulico(this.area_entrepantallas, 2 * (this.ancho + this.espaciamiento_pantallas))
    this.anchohueco = 0.3
    this.altohueco = 0.2
  }


  Q = (q) => h.q_m3s(q);
  tiempo = (q) …
Run Code Online (Sandbox Code Playgroud)

javascript functional-programming class reactjs es6-class

2
推荐指数
1
解决办法
6374
查看次数