2022-10-24 记录uniapp根据条件编译从而使部分代码在不同的条件下生效
条件编译写法 | 说明 |
---|---|
#ifdef APP-PLUS
需条件编译的代码 #endif |
仅出现在 App 平台下的代码 |
#ifndef H5
需条件编译的代码 #endif |
除了 H5 平台,其它平台均存在的代码 |
#ifdef H5 || MP-WEIXIN
需条件编译的代码 #endif |
在 H5 平台或微信小程序平台存在的代码(这里只有||,不可能出现&&,因为没有交集) |
来源:https://uniapp.dcloud.net.cn/tutorial/platform.html#preprocessor