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

条件编译介绍:

条件编译是用特殊的注释作为标记,在编译时根据这些特殊的注释,将注释里面的代码编译 到不同平台。

#ifdef和#ifndef的区别:

#ifdef APP-PLUS------------只在APP显示

#ifndef APP-PLUS------------除了APP不显示,其他的都显示

javascript 复制代码
// #ifdef H5
	uni.chooseImage({
		count: 1,
		sizeType: ['original', 'compressed'],
		// sourceType: ['album'], //从相册选择
		success: function (res) {
			this.setImage({path: res.tempFilePaths,dotype:type})
			console.log(res.tempFilePaths)
		}
	});
// #endif
// #ifndef H5
	switch (type) {
		case 'face':
			uni.navigateTo({
				url: '/pages/camera/idcard/idcard?dotype=face'
			})
		    break;

		default:
			uni.navigateTo({
				url: '/pages/camera/camera'
			})
	}
// #endif
相关推荐
BS30813_vx2 小时前
基于 Express + uni-app 的养老院管理系统设计与实现
后端·uni-app·express
bug总结4 小时前
uniapp 微信小程序请求规范
微信小程序·小程序·uni-app
梦曦i1 天前
unix-router v0.1.0 首发:uni-app x 的 vue-router 风格路由库
前端·uni-app
bug总结2 天前
uniapp 微信小程序分包规范
微信小程序·小程序·uni-app
天府云创2 天前
uni-app X 蒸汽模式发布!性能比肩原生~
前端框架·uni-app·移动开发·原生应用·蒸汽模式·app研发·多端适配
堕落年代2 天前
uni-app x 蒸汽模式:实时流式语音识别(ASR)三大疑难杂症全记录
人工智能·uni-app·语音识别
RisunJan2 天前
uni-app 高频面试题与解答
uni-app
梦曦i3 天前
@meng-xi/create-uni-app vs unibest:轻量脚手架与重型框架的定位之争
前端·uni-app
2501_915106323 天前
iOS数据采集技术详解:从性能监控到崩溃分析的全链路实践
android·ios·小程序·https·uni-app·iphone·webview
我爱写代码i4 天前
AI对话绘画数字人源码 - uniapp前端
前端·人工智能·uni-app