微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在 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 举报,一经查实,本站将立刻删除。