uni-app条件编译(跨端兼容)、pages.json 的条件编译
·
<template>
<view class="content">
<!-- #ifdef H5 -->
<view>
H5
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view>
微信小程序
</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
onLoad() {},
data() {
return {
}
},
methods: {}
}
</script>
<style scoped lang="scss">
.content {}
</style>
详细介绍条件编译,官方地址链接:https://uniapp.dcloud.io/platform
pages.json 的条件编译
<template>
<view class="content">
pages.json的条件编译,点击XYZ在微信里面是不会跳转到test.vue里面,而在
H5页面点击XYZ会跳转到test.vue里面来,注意在pages.json文件里面写条件编译的
时候一定要注意逗号要写在//#ifdef H5 ......//#endif里面,不然微信端会报错,
为什么会报错,还请知道的大佬留个言!
<view class="test" @tap="test">XYZ</view>
</view>
</template>
<script>
export default {
methods: {
test() {
uni.navigateTo({
url: '../../test/test',
success: res => {},
fail: () => {},
complete: () => {}
});
}
}
}
</script>
<style scoped lang="scss">
.content {
.test {
border: 1px solid #ff0000;
font: {
size: 20rpx;
weight: 600;
color: #ff0000;
}
}
}
</style>
pages.json文件里面的内容我就贴个图片:

详细介绍pages.json 的条件编译,官方地址链接:https://uniapp.dcloud.io/platform?id=pagesjson-%e7%9a%84%e6%9d%a1%e4%bb%b6%e7%bc%96%e8%af%91
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)