import React from "react";
import styles from './index.css';
export const NumTostring = e => {
    const num = e.children-0;
    if (typeof num === 'number' && !isNaN(num)) {
        /**
         * 数字包裹
         * @param {number} num  - 要处理的数字
         * @param {string} warp  - 要处理的数字
         * @return {array} html - 返回html arr字符串
         **/
        let str = num + '';
        let html = [];
        for (let i = 0; i < str.length; i++) {
            html.push(<span key={i} className={styles.num} > {str.substr(i, 1)}</span>);
        }
        return html;
    } else if(isNaN(e.children)) {
        return '';
    }else{
        return num;
    }
}