uni-app条件编译:#ifdef #ifndef #endif
<p>语法:</p><div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> #ifdef %PLATFORM% </span><span style="color: rgba(0, 0, 0, 1)">
这些代码只在该平台编译
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> #endif</span></pre>
</div>
<div class="cnblogs_code">
<pre>#ifdef : <span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> defined 仅在某个平台编译
#ifndef : </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> not defined 在除里该平台的其他编译
#endif : end </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> 结束条件编译
</span>%PLATFORM% 需要编译的平台,上面的MP就是各个小程序的意思</pre>
</div>
<div class="cnblogs_code">
<pre>uni-<span style="color: rgba(0, 0, 0, 1)">app支持的各个平台</span></pre>
<table style="height: 248px; width: 701px" align="left">
<thead>
<tr><th>值</th><th>平台</th><th>参考文档</th></tr>
</thead>
<tbody>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">APP-PLUS</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">5+App</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">HTML5+ 规范</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">APP-PLUS-NVUE</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">5+App nvue</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">Weex 规范</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">H5</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">H5</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"> </span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP-WEIXIN</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">微信小程序</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">微信小程序</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP-ALIPAY</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">支付宝小程序</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">支付宝小程序</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP-BAIDU</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">百度小程序</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">百度小程序</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP-TOUTIAO</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">头条小程序</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">头条小程序</span></span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP-QQ</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">QQ小程序</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">(目前仅cli版支持)</span></td>
</tr>
<tr>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">MP</span></td>
<td><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)">微信小程序/支付宝小程序/百度小程序/头条小程序/QQ小程序</span></td>
<td style="margin-left: 90px"><span style="font-family: 仿宋; font-size: 14px; color: rgba(0, 0, 0, 1)"> </span></td>
</tr>
</tbody>
</table>
<pre><span style="color: rgba(0, 0, 0, 1)"><br><br><br><br></span></pre>
</div>
<div class="table-box"> </div><br><br>
来源:https://www.cnblogs.com/shurun/p/11935451.html
頁:
[1]