return [
'lm-<name>' => ['home/lm/index', ['method' => 'GET'], ['name' => '\w+']],
'show-<id>' => ['home/content/index', ['method' => 'GET'], ['id' => '\d+']],
];这是生成URL函数function urlContent($data = [])
{
$id = $data['content_id'];
$u = url('home/content/index', ['id' => $id]);
return $u;
}layui table组件中使用呢?之前没有使用table组件时,直接在循环中vo中,链接直接:urlContent($vo)
现在我是这样,定义JS的URL地址:
var IndexUrl = {
index: "{:url('ajax')}",
add: "{:url('add')}",
edit: "{:url('edit')}",
del: "{:url('delete')}",
link: "{:url('home/content/index')}"
};table模板:<script type="text/html" id="titleTpl">
<div><a href="{{ IndexUrl.link }}?id={{ d.content_id }}" target="_blank">{{ d.content_title }}</a></div>
</script>这样如果是没有使用:路由,可以访问,链接是:/home/content/index.html?id=xxxxx
如果路由了,就不能访问了,我该怎么定义呢??
最佳答案