条件编译#ifdef

<template>
    MP是指代所有小程序
    ifdef 只在MP设备会编译代码块里面的代码
    <!-- #ifdef MP -->
        <button open-type="contact">点击会直接打开微信小程序后台配置的客服聊天,h5不生效</button>
    <!-- #endif -->
    ifndef 除了H5设备外都会编译代码块里面的代码
    <!-- #ifndef H5 -->
    
    <!-- #endif -->
    可以使用联合
    <!-- #ifdef APP || H5-->
    
    <!-- #endif -->
</template>

<script setup>
    
</script>

<style scoped lang="scss">
// 在style里面也可以使用条件编译    
/* #ifdef APP */

/* #endif */
</style>

 

posted on 2025-03-03 15:56  ChoZ  阅读(9)  评论(0)    收藏  举报

导航