在引导表的数据格式化程序函数中显示 php 数据



我已经table.php文件中创建了一个引导表,并使用数据格式化程序定义了一个表标题,如下所示

<th data-field='edit' data-formatter="editFormatter">Edit</th>

我为此创建了功能,

function editFormatter(value, row)
{
return `<a href="<?= URL::to('xyz/label'); ?>"  ><i class="fa fa-pencil sg-edit-btn" ></i></a>`
}

但是当我检查table.php页面上时,它显示这样的锚点,

<a href="<?= URL::to('xyz/label'); ?>

为什么PHP代码不会像这样转换,

<a href="https://localhost/app/public/xyz/label" class="btn sg-primary-btn">

有什么办法吗?提前感谢

var data = [{
"url": "https://www.stackoverflow.com",
"nice_name": "Stackoverflow"
}, {
"url": "https://www.facebook.com",
"nice_name": "Facebook"
}];
function linkFormatter(value, row) {
return "<a href='" + row.url + "'>" + row.nice_name + "</a>";
}
$(function() {
$('#table').bootstrapTable({
data: data
});
});
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.css">
<table data-toggle="#table" id="table">
<thead>
<tr>
<th data-field="url" data-formatter="linkFormatter" data-sortable="true">Link</th>
</tr>
</thead>
</table>

最新更新