網站首頁 編程語言 正文
目錄
- uni-app之 條件注釋 實現跨端兼容
- 頁面視圖的 相關顯示
- js代碼之中 區分不同端 顯示
- css的 不同端口顯示
uni-app之 條件注釋 實現跨端兼容
- 官網
- #ifdef:if defined 僅在某平臺存在
- #ifndef:if not defined 除了某平臺均存在
- %PLATFORM%:平臺名稱
頁面視圖的 相關顯示
-
我希望在h5看見
- 只是在h5顯示
-
在小程序看見
- 只是在微信小程序顯示
<template>
<view>
<!-- #ifdef H5 -->
<view class="">我希望在h5看見</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="">在小程序看見</view>
<!-- #endif -->
</view>
</template>
- 效果
js代碼之中 區分不同端 顯示
- // #ifdef H5 XX // #endif
- // #ifdef MP-WEIXIN XX // #endif
<script>
export default {
onLoad(){
// #ifdef H5
console.log("我只是在H5顯示");
// #endif
// #ifdef MP-WEIXIN
console.log("我只是在小程序顯示");
// #endif
}
}
</script>
- 效果
css的 不同端口顯示
<template>
<view>
<!-- #ifdef H5 -->
<view class="">我希望在h5看見</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="">在小程序看見</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
data(){
return {
imgArr:[]
}
},
methods: {
},
}
</script>
<style lang="scss">
view {
// #ifdef H5
color: red;
// #endif
// #ifdef MP-WEIXIN
color: blue;
// #endif
}
</style>
- 效果
原文鏈接:https://blog.csdn.net/weixin_43845137/article/details/124026112
- 上一篇:uni-app之項目首頁實現步驟
- 下一篇:es6及之后的剩余參數
相關推薦
- 2023-01-26 Redis中的慢日志_Redis
- 2022-07-11 npm 查看全局安裝和卸載全局安裝
- 2022-05-17 Error running ‘myToncat‘: Address localhost:8080 i
- 2022-08-15 Elasticsearch文檔查詢詳解
- 2022-08-10 詳細聊一聊algorithm中的排序算法_C 語言
- 2022-09-26 go語言標準庫fmt包的一鍵入門_Golang
- 2022-02-23 關于zabbix自定義監控項和觸發器問題_zabbix
- 2022-06-10 使用Android實現一個懸浮在軟鍵盤上的輸入欄_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支