1、视图分别显示:
<!-- #ifdef H5 -->
<view>我希望仅在H5中显示</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view>我希望仅在WX小程序中显示</view>
<!-- #endif -->
2、js里实现分别各自调用:
onLoad() {
// #ifdef H5
console.log("我希望仅在网页中显示");
// #endif
// #ifdef MP-WEIXIN
console.log("我希望仅在微信小程序中打印");
// #endif
}
3、css里实现分别各自的样式:
<style>
/* 在H5中的样式 */
/* #ifdef H5 */
view{
color:pink;
}
/* #endif */
/* 在WX小程序中的样式 */
/* #ifdef MP-WEIXIN */
view{
color:blue;
}
/* #endif */
</style>