为什么 Tabulator 会给出带有“</script>”字样的数据错误?

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

使用制表符,例如,如果我从具有以下值的记录中获取数据,则它可以工作:“”,但如果我输入:“”,它就会中断。问题具体在于。

<!DOCTYPE html>
<html lang="en">
    <head>      
        <link href="https://unpkg.com/tabulator-tables/dist/css/tabulator.min.css" rel="stylesheet">
        <script type="text/javascript" src="https://unpkg.com/tabulator-tables/dist/js/tabulator.min.js"></script>  
    </head>
    
    <body>
        <div id="example-table"></div>

        <script> 
                
            //sample data
            var tabledata = [
                {id:1, name:"Oli Bob" },
                {id:2, name:"Mary May"},
                {id:3, name:"Christine Lobowski"},
                {id:4, name:"<button>Margret Marmajuke</button>"}           
            ];
            
            var table = new Tabulator("#example-table", {
                height:200, // set height of table to enable virtual DOM
                data:tabledata, //load initial data into table
                layout:"fitColumns", //fit columns to width of table (optional)
                columns:[ //Define Table Columns                    
                    {title:"Name", field:"name", sorter:"string", formatter: 'text'}
                ],
            });
            
            //trigger an alert message when the row is clicked
            table.on("rowClick", function(e, row){
                alert("Row " + row.getIndex() + " Clicked!!!!");
            });
        </script>

    </body>
</html>

如果我添加这一行,它就不起作用

{id:5, 名称:""}

但也许如果我像这样逃避它,是的

{id:5, 名称:"

请问有没有办法格式化或解决?

我希望能够在列中显示这个文字->“

javascript html tabulator formatter
© www.soinside.com 2019 - 2024. All rights reserved.