您的位置:首页 > 游戏 > 游戏 > uniapp条件编译使用教学(#ifdef、#ifndef)

uniapp条件编译使用教学(#ifdef、#ifndef)

2024/10/6 14:34:51 来源:https://blog.csdn.net/qq_42915565/article/details/141156192  浏览:    关键词:uniapp条件编译使用教学(#ifdef、#ifndef)
  1. #ifdef //仅在xxx平台使用
  2. #ifndef //除了在xxx平台使用
  3. #endif // 结束
标识平台
APP-PLUSAPP
MP微信小程序/支付宝小程序/百度小程序/头条小程序/QQ小程序
MP-WEIXIN微信小程序
MP-ALIPAY支付宝小程序
MP-BAIDU百度小程序
MP-TOUTIAO头条小程序
MP-QQQQ小程序
H5H5
APP-PLUS-NVUEApp nvue

这个条件编译可以在js,css,html中使用,不过使用时需要注释掉,比如

html

<!-- #ifdef MP -->
<slot name="{{item.dataIndex}}" :text="data[item.dataIndex]" :record="data" :index="dataIndex"/>
<!-- #endif -->
<!-- #ifndef MP -->
<slot :name="item.dataIndex" :text="data[item.dataIndex]" :record="data" :index="dataIndex"/>
<!-- #endif -->

js

// #ifdef H5
this.getBlob(data.url).then((blob) => {this.saveAs(blob, data.name);
});
// #endif
// #ifdef APP-PLUS
this.appDownloadFile(data)
// #endif

css

/* #ifdef MP-ALIPAY */
.cu-custom .cu-bar .action .cuIcon-back {opacity: 0;
}/* #endif */.cu-custom .cu-bar .content image {height: 60upx;width: 240upx;
}.cu-custom .cu-bar {min-height: 0px;/* #ifdef MP-WEIXIN */padding-right: 220upx;/* #endif *//* #ifdef MP-ALIPAY */padding-right: 150upx;/* #endif */box-shadow: 0upx 0upx 0upx;z-index: 9999;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com