Blogger Information
Blog 77
fans 0
comment 2
visits 55668
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用克隆,传递被克隆的数据类型(TS)
南瓜又个梦
Original
762 people have browsed it

在要对拿到的数据进行处理的时候,基于数据可能放于对象中,或者处理数据但是不改变数据源,需要对数据进行复制克隆时,等号两边的数据类型可能存在不同,一下代码解决数据转换前后数据类型一致。

  1. function clone<T>(data:T):T{
  2. return ......(data)
  3. }
  4. export default clone
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post