//在js中使用U函数,带js参数
if(data){
//参数使用js变量,在js中不能将id等参数移到U()函数中,会出错
location.href="{:U('articleCatDel')}?id="+data.id+"&opt="+data.opt;
}//在js中使用U函数,带php参数 //参数中使用php数组变量,在js中不能使用array()参数写法
location.href="{:U('articleCatDel')}?id={$data[id]}&opt={$data[opt]}";//在html中使用U函数//一个参数的写法(向U()函数传入两个字符串参数的形式):
<a href="{:U('index','model_id='.$info['model_id'])}">返回列表</a>//一个参数的写法(向U()函数传入一个字符串参数的形式):<a href="{:U('index?model_id='.$info['model_id'])}">返回列表</a>//多个参数写法一(两个字符串参数形式):<a href="{:U('article/index','cate_id='.$info['category_id'].'&pid='.$article['id'])}">{$article.title}</a>感谢网友 lzhf237 提供的数组形式的写法:<a href="{:U('article/index',array('cate_id'=>$info['category_id'],'pid'=>$article['id']))}">{$article.title}</a>//多个参数写法二(一个字符串参数形式):<a href="{:U('Article/edit?cate_id='.$vo['category_id'].'&id='.$vo['id'])}">编辑</a>感谢网友 LinTx 提供的更简捷的写法:<a href="{:U('Article/edit?cate_id=$vo[category_id]&id=$vo[id]')}">编辑</a>//多个参数写法三<foreach>:<foreach name="groups" item="vo">
<neq name="group_id" value="$key"><a href="{:U('AuthManager/access?group_name='.$vo['title'].'&group_id='.$vo['id'])}">$vo['name']</a><else/><strong>$vo['name']</strong></neq>
</foreach>//多个参数写法四<volist>:<volist name="model" id="vo">
<li>
<a href="{:U('User/changeStatus?method=resumeUser&id='.$vo['uid'])}" class="ajax-get">启用</a></li>
</volist>//多个参数写法五,在U()函数中可以使用I()函数:<a class="sch-btn" href="javascript:;" id="search" url="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id,false)}"><i class="btn-search"></i></a>(完) 最佳答案