最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

uniapp?APP和微信小程序橫屏模式實(shí)現(xiàn)代碼

 更新時(shí)間:2026年01月12日 08:51:13   作者:熱心市民禾呈先森??  
這篇文章主要介紹了uniapp?APP和微信小程序橫屏模式實(shí)現(xiàn)的相關(guān)資料,通過(guò)在pages.json文件中添加特定的配置代碼,可以在進(jìn)入指定頁(yè)面時(shí)自動(dòng)將小程序橫屏顯示,需要的朋友可以參考下

首先在pages.json下新增代碼:

"globalStyle": {
		"navigationBarTextStyle": "black",
		"navigationBarTitleText": "uni-app",
		"navigationBarBackgroundColor": "#F8F8F8",
		"backgroundColor": "#F8F8F8",
		"pageOrientation": "auto" //橫屏配置 auto自動(dòng) | portrait豎屏 | landscape橫屏
	},

微信小程序橫屏:

pages.json下添加代碼(進(jìn)入頁(yè)面自動(dòng)橫橫屏):

{
			"path": "pages/native/demo",
			"style": {
				"navigationBarTitleText": "橫屏模式",
				"enablePullDownRefresh": false,
				"backgroundTextStyle": "dark",
				"mp-weixin": {
					"pageOrientation": "landscape" //auto:自動(dòng),landscape:橫屏,portrait :豎屏
				}
			}
		}

頁(yè)面代碼實(shí)現(xiàn):

<template>
	<view class="">
		<button type="default" @click="onCrosswise('default')">默認(rèn)橫豎屏切換</button>
		<button type="default" @click="onCrosswise('portrait')">豎屏</button>
		<button type="default" @click="onCrosswise('landscape')">橫屏</button>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		watch,
		onMounted,
	} from "vue"
	import {
		onLoad,
		onReady,
		onUnload
	} from '@dcloudio/uni-app'

// 切換模式
	const onCrosswise = (mode) => {
		if (mode == 'default') {
			// #ifdef APP-PLUS
			plus.screen.lockOrientation('default'); // 默認(rèn)橫豎屏切換
			// #endif
		} else if (mode == 'portrait') {
			// #ifdef APP-PLUS
			plus.screen.lockOrientation('portrait-primary'); // 豎屏展示
			// #endif
		} else {
			uni.navigateTo({
				url: "/pages/native/demo",
				success: function(res) {
					// #ifdef APP-PLUS
					plus.screen.lockOrientation('landscape-primary'); // 強(qiáng)制橫屏
					// #endif
				}
			})
		}
	}
</script>

/pages/native/demo頁(yè)面:

<template>
	<view class="">
		跳轉(zhuǎn)成功
	</view>
</template>

<script setup>
	import {
		onLoad,
		onReady,
		onUnload
	} from '@dcloudio/uni-app'
	//頁(yè)面卸載時(shí)切換為默認(rèn)或者其他屬性
	onUnload(() => {
		{
			// #ifdef APP-PLUS
			plus.screen.lockOrientation('default');
			// #endif
		}
	})
</script>

<style>
</style>

總結(jié) 

到此這篇關(guān)于uniapp APP和微信小程序橫屏模式的文章就介紹到這了,更多相關(guān)uniapp APP和小程序橫屏模式內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

娱乐| 舒城县| 乌兰浩特市| 潮安县| 通道| 尖扎县| 谷城县| 新泰市| 新田县| 衡阳县| 上蔡县| 安远县| 杂多县| 连江县| 隆尧县| 佛坪县| 沅江市| 霍山县| 阳曲县| 家居| 凌云县| 临朐县| 松潘县| 天峻县| 崇明县| 射洪县| 德安县| 眉山市| 若尔盖县| 周口市| 平江县| 蕉岭县| 仁怀市| 凌源市| 宜阳县| 南投县| 宝丰县| 新建县| 黔西县| 汕头市| 通许县|