gantt.parse或gantt.load的无效参数(laravel和vuejs)

问题描述 投票:0回答:1

我试图在项目中使用Dhtmlx库构建甘特图,所以我尝试在gantt.load函数中传递项目的ID以仅显示该项目的甘特图。但是它向我显示了这些错误“ gantt.parse或gantt.load的无效参数。应使用对象或格式为https://docs.dhtmlx.com/gantt/desktop__supported_data_formats.html#json的JSON字符串。实际参数值:“ failed”“任何帮助的人???这是我的Gantt.vue:

 <template>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
               <div class="card-body">

                <div id="gantt_here">

                 </div>

                </div>

         </div>
        </div>
    </div>
</div>

 </template>

<script>

export default {

    data(){
        return{
               key: this.$route.params.id,


        }
    },
    created(){

gantt.config.xml_date = "%Y-%m-%d %H:%i:%s";
gantt.config.order_branch = true;/*!*/
gantt.config.order_branch_free = true;/*!*/
gantt.init("gantt_here");

gantt.load("/api/data/"+this.key);

var dp = new gantt.dataProcessor("/api");/*!*/
dp.init(gantt);/*!*/
dp.setTransactionMode("REST");/*!*/

    },
    mounted() {

            console.log('Component mounted.')
    }
}

这是我的GanttController:

<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Task;
use App\Link;

  class GanttController extends Controller
   {
public function get($id){
    $tasks= new Task;
 if($tasks->projet_id== $id){
    $tasks = new Task();
    $links = new Link();

    return response()->json([
        "data" => $tasks->orderBy('sortorder')->get(),
        "links" => $links->all()
    ]);
 }
 else{
  return response()->json([
    "failed"
            ]);
 }
 }

}

这是我在api.php中的路线:Route::get('/data/{id}', 'API\GanttController@get');

laravel vue.js laravel-6 gantt-chart dhtmlx
1个回答
0
投票

Gantt需要JSON格式的数据。但是gantt.load()方法不会将参数分别发送到服务器端。您可以尝试使用自定义路由,但是需要手动实现将数据发送到服务器端的功能,然后可以将其添加到"create""update""delete"操作中:https://docs.dhtmlx.com/gantt/desktop__server_side.html#customrouting

© www.soinside.com 2019 - 2024. All rights reserved.