当前位置: 移动技术网 > IT编程>网页制作>CSS > 不存在值检测操作符

不存在值检测操作符

2019年11月22日  | 移动技术网IT编程  | 我要评论

谢紫彬,谢依彤胸围,乔洋的图片

使用形式: unsafe_expr?? 或 (unsafe_expr)??

这个操作符告诉我们一个值是否存在。基于这种情况, 结果是 true 或 false

访问非顶层变量的使用规则和默认值操作符(上一篇)也是一样的, 也就是说,可以写 product.color?? 和 (product.color)??

 

示例如下,假设并没有名为 mouse 的变量:

 

<#if mouse??>
  mouse found
<#else>
  no mouse found
</#if>
creating mouse...
<#assign mouse = "jerry">
<#if mouse??>
  mouse found
<#else>
  no mouse found
</#if>

 

将会输出:

 

  no mouse found
creating mouse...
  mouse found

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网