網站首頁 編程語言 正文
目錄
- 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及之后的剩余參數
相關推薦
- 2024-01-07 IDEA中自動導包及快捷鍵
- 2022-11-17 python標準庫random模塊處理隨機數_python
- 2022-09-13 C++中string使用+號與int拼接方式_C 語言
- 2022-06-16 golang?validator庫參數校驗實用技巧干貨_Golang
- 2022-02-12 Cognos Sample for Oracle數據源
- 2022-09-16 Go?WEB框架使用攔截器驗證用戶登錄狀態實現_Golang
- 2022-03-05 Android中CountDownTimer類詳解_Android
- 2022-04-15 C語言的位段與枚舉詳解_C 語言
- 最近更新
-
- 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同步修改后的遠程分支