制表符 ajaxURL 添加问号结束

Tabulator ajaxURL adding a question mark to end

我正在为一个项目使用 wagtail/django,并且正在尝试对制表符进行 ajax 调用。我目前有这个

var table = new Tabulator("#example-table", {
    ajaxURL:"http://localhost:8000/api/v2/people/?fields=*", //ajax URL
    ajaxConfig:{
        method:"get", //set request type to Position
        headers: {
            "Content-type": 'application/json; charset=utf-8', //set specific content type
        },
    },
    height:"311px",
    layout:"fitColumns",
    placeholder:"No Data Set",
    columns:[
        {title:"Name", field:"name", sorter:"string", width:200},
        {title:"Date", field:"date", sorter:"string"},
    ],
});

table.setData();

但是我在浏览器中的调试控制台有

Request URL:http://localhost:8000/api/v2/people/?fields=*?
"message": "fields error: unexpected char '?' at position 1"

为什么要在末尾添加问号?如果我在 Django Rest Page 的末尾添加一个问号,我可以复制相同的错误。

添加 ? 是因为这是将附加参数传递给 URL 的标准方法,显然 Tabulator 不会检查 ajaxURL 是否已经有一个。您可以通过将 fields 参数移动到 ajaxParams 来解决此问题,它将与 Tabulator 可能传递的任何其他参数组合:

var table = new Tabulator("#example-table", {
    ajaxURL:"http://localhost:8000/api/v2/people/",
    ajaxParams: {'fields': '*'},
    ajaxConfig:{
        method:"get", //set request type to Position
        headers: {
            "Content-type": 'application/json; charset=utf-8', //set specific content type
        },
    },
    height:"311px",
    layout:"fitColumns",
    placeholder:"No Data Set",
    columns:[
        {title:"Name", field:"name", sorter:"string", width:200},
        {title:"Date", field:"date", sorter:"string"},
    ],
});