{{C?A:B}}
C条件成立则为A,不存在取B
比如在跟后台交互时,有许多要设默认值
<script type=''text/javascript>
var value = document.getElementById('input');
var type = value?value:0; //比如给后台传值,如果不存在,就设一个默认值,保证程序正常运行
</script>
实例:
<script type=''text/javascript>
var a = true;
var b = (a = true)?1:2; //b =1
</script>