后端使用laravel将参数传递给前端,但是前端无法正常显示数据,请问到底是哪里出了问题?
laravel 代码:
 $res = historydata::where('product_id','1')->get();                        //将获取的数据重新排版            if(count($res) > 0){                foreach( $res as $value){                    $timestamp = strtotime(str_replace('/','-',$value['time']));                    $data[] = [ $timestamp , $value['cumulativenet']];                }            }                        //highchart设置内容                        //x坐标轴            $highchart['xaxis'] = [ 'title' => [ 'text' => '时间' ] ];                        //y坐标轴            $highchart['yaxis'] = [ 'title' => [ 'text' => '净值' ] ];                        //数据            $highchart['series'] = [ 'name'=>'净值' , 'data' => $data ];                        $highchart['rangeselector'] = array( 'selected' => '1' );
html代码
json数据
{    xaxis: {        title: {            text: 时间        }    },    yaxis: {        title: {            text: 净值        }    },    series: {        name: 净值,        data: [            [                1441900800,                1            ],            [                1439222400,                1            ]        ]    },    rangeselector: {        selected: 1    }}
回复内容:                                                                                  后端使用laravel将参数传递给前端,但是前端无法正常显示数据,请问到底是哪里出了问题?
laravel 代码:
 $res = historydata::where('product_id','1')->get();                        //将获取的数据重新排版            if(count($res) > 0){                foreach( $res as $value){                    $timestamp = strtotime(str_replace('/','-',$value['time']));                    $data[] = [ $timestamp , $value['cumulativenet']];                }            }                        //highchart设置内容                        //x坐标轴            $highchart['xaxis'] = [ 'title' => [ 'text' => '时间' ] ];                        //y坐标轴            $highchart['yaxis'] = [ 'title' => [ 'text' => '净值' ] ];                        //数据            $highchart['series'] = [ 'name'=>'净值' , 'data' => $data ];                        $highchart['rangeselector'] = array( 'selected' => '1' );
html代码
json数据
{    xaxis: {        title: {            text: 时间        }    },    yaxis: {        title: {            text: 净值        }    },    series: {        name: 净值,        data: [            [                1441900800,                1            ],            [                1439222400,                1            ]        ]    },    rangeselector: {        selected: 1    }}
前端不现实,无非就是前端展现有问题,或者你提供的数据格式并不是它希望得到的格式。
   
 
   