TP5伪静态路径写法
路由设置:
route.php
<?php
// ThinkAdmin
use think\facade\Request;
use think\facade\Route;
//定义路由规则
//企业站
Route::rule('about/[:cateid]','index/index/about');
Route::rule('yuanli/[:cateid]','index/index/yuanli');
Route::rule('fangan/[:cateid]','index/index/fangan');
Route::rule('jiameng/[:cateid]','index/index/jiameng');
Route::rule('lianxi/[:cateid]','index/index/lianxi');
Route::rule('jianjie/[:cateid]','index/index/jianjie');
Route::rule('xiangqing/:id','index/index/xiangqing');
//商城
Route::rule('shopxq/:id','shop/shop/shopxq'); //详情
Route::rule('cate/[:pid]/[:id]/[:onShelf]/[:sale]/[:fontprice]','shop/shop/cate');
//二级分类
Route::rule('login','shop/shop/login'); //登录
Route::rule('checklogin','shop/shop/checklogin'); //检测登录
Route::rule('phonesms','shop/shop/phonesms'); //获取短信验证码
Route::rule('register','shop/shop/register'); //注册
Route::rule('checkregister','shop/shop/checkregister'); //注册
Route::rule('shopmore/[:type]/[:onShelf]/[:sale]/[:fontprice]','shop/shop/shopmore');
//首页更多跳转 热卖 新品 精选
Route::rule('help/[:id]','shop/shop/help'); //帮助中心
Route::rule('vip/[:type]','shop/shop/vip'); //会员中心
Route::rule('vip2','shop/shop/vip2'); //会员中心
Route::rule('order','shop/shop/order'); //我的订单
模板页面使用:
例一:
{:url('shop/shop/vip',['type'=>1])}
<a href="{:url('shop/shop/vip',['type'=>1])}" >订单管理</a>
例二:
{:url('/vip',['type'=>1])}
<a href="{:url('/vip',['type'=>1])}" >订单管理</a>
例三:
var name=$('#search').val()
window.location.href="{:url('/search')}?name="+ name
<script>
$(document).ready(function () {
$("#search").keypress(function (e) {
if (e.which == 13) {
var name=$('#search').val()
window.location.href="{:url('/search')}?name="+ name
}
});
})
$('.tovplay').click(function(){
if('{$Think.session.phone}'){
var mid='{$Think.session.id}'
var id=$(this).attr('data-id')
var type=$(this).attr('data-type')
window.location.href ="{:url('/vplay/"+id+"/"+type+"')}"
}else{
window.location.reload()
}
})
</script>
参考文章: https://blog.csdn.net/haibo0668/article/details/78052850/
参考文章:https://www.jb51.net/article/187356.htm
TP5 url链接(带参数)的写法
{:url(‘Liuyan/add’)}
例子:
还没有评论,来说两句吧...