亚洲城娱乐javascript导出csv时,设置中文编码,时间格式会被改变

( 亚洲城娱乐 )

    <script type="text/javascript">
    var data = [{
        "0": "Rank",
        "1": "Country",
        "2": "Population",
        "3": "% of world population",
        "4": "Date",
        "length": 5
    }, {
        "0": "1",
        "1": "中华人民共和国 China",
        "2": "1,370,570,000",
        "3": "18.9%",
        "4": "June 24, 2015",
        "length": 5
    }];

    function json2csvdata{
        forvar i=0;i<data.length;i++{
            delete data[i].length;
        }

        var str = JSON.stringifydata;

        console.logone:,str,


;

        str = str.slice2,str.length-2;

        console.logtwo:,str,


;

        str = str.replace"},{",


        str = str.replace/"[0-9]+":/g,;
         var encodedUri = encodeURI"data:text/csv;charset=gb2312,ufeff"+str;

        window.openencodedUri;
    }

    json2csvdata;
    </script>

javascript导出csv时,设置中文编码,时间格式会被改变,而我只想中文不乱码,时间格式不变,该怎么处理?

(看完/读完)这篇文章有何感想! 亚洲城娱乐的分享…

发表评论

电子邮件地址不会被公开。 必填项已用*标注