thinkphp3.2.3模板渲染支持三元表达式
thinkphp3.2.3模板渲染支持三元表达式
{$status?'正常':'错误'} {$info['status']?$info['msg']:$info['error']}
注意:三元运算符中暂时不支持点语法。
如下:
<div class="modal hide fade" id='myModal'> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header" style='background-color: #0ca5ec'> <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="color:white;opacity:0.6;">×</button> <h3 style="color:white">某某某融资网</h3> </div> <div class="modal-body"> <p style="text-align:center;color:red;font-size:18px;line-height:20px;padding:0 0 4px 0;">{$popAcData['a_popStatus']?$popAcData['a_Title']:$popHuigu['n_Title']}</p> <img src="{$popAcData['a_popStatus']?$popAcData['a_Photo']:$popHuigu['n_Image']}" alt="{$popAcData['a_popStatus']?$popAcData['a_Title']:$popHuigu['n_Title']}"> </div> <div class="modal-footer"> <a href="javascript:void(0);" class="btn">关闭</a> <a href="javascript:void(0);" class="btn btn-primary">{$popAcData['a_popStatus']?查看活动详情:查看活动回顾}</a> </div> </div> </div> </div>
<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/jquery-3.1.0.min.js'></script>
<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/bootstrap.min.js'></script>
<script type="text/javascript" src='__PUBLIC__/popUp/popUp-js/popUp.js'></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function(){
//活动开始显示弹窗 活动没开始读活动回顾
$j('#myModal').modal('show');
var btn = $j('.btn');
btn.eq(0).click(function(){
$j('#myModal').modal('hide');
});
btn.eq(1).click(function(){
$j('#myModal').modal('hide');
window.location.href={$popAcData['a_popStatus']}?"{:U('/Activity/detail',array('a_Id'=>$popAcData['a_Id']))}":"{:U('/News/newsContent',array('n_Id'=>$popHuigu['n_Id']))}";
});
})
</script>
参看上面例子中的三元表达式加以运用哦
作者:子钦加油
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年