在 array_sum 中格式化数组中的数字

问题描述

我在 laravel 项目中有一个视图,我必须打印一些数组列的总和。

我有这样的代码来实现结果:

// First of all define some "private" subjects
// Subjects are used to allow multicasting,i.e. more clients sharing the same stream
const _isLoading$ = new BehavIoUrSubject<boolean>(false);
const _state$ = new Subject<any>();

// Then define the "public" API streams,i.e. the streams the clients can subscribe to
// isLoading$ notifies when the isLoading value changes
export const isLoading$ = _isLoading$.asObservable();
// state$ notifies when the state value changes
export const state$ = _state$.asObservable();

// Now we define a function to fire the fetch and the relative changes in isLoading
export fetch() = () => {
  // first we notify that isLoading is true
  _isLoading$.next(true)
  // then we fire the fetch operation
  from(fetch(....))  // from transforms a Promise to an Observable
  // pipe applies the transformations you need to the data notified by the upstream 
  // as well as fires side effects
  .pipe(
    // as soon as the fetch operation returns we notify the change in isLaoding
    tap({
      next: () => _isLoading$.next(false),error: () => _isLoading$.next(false) // you can do more if you want with the error
    }),// finally we apply the required transformations
    map(data => {
      const newState = // do anything you need to create the new state with the data fetched
      return newState
    }),// eventually you notify the changes in the state using the private Subject
    tap(_state$)
  )
}

它工作正常。但是有一个问题。

数字列有一个格式化的意大利货币数字,如下所示:

1.267,76 欧元

所以总和打印错误,因为数字有错误的格式来执行总和。

在刀片视图中执行求和之前,如何将所有数字格式化为 1267.76?

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)