兼容低版本安卓电视,使用原生html配合jquery开发H5+app,实现底部导航栏功能

 需求:为了在低版本安卓电视机内展示app,而H5的mui框架底部导航栏无法响应遥控器的点击事件,所以页面需求需要使用原生开发。

  实际效果:

  代码如下: 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title></title>
		<script src="./js/jquery-3.7.1.js"></script>
		<style type="text/css">
			body {
				position: relative;
				width: 100vw;
				height: 100vh;
				margin: 0;
			}

			.buttom_nag {
				width: 100vw;
				height: 7vh;
				position: fixed;
				bottom: 0;
				left: 0;
				display: flex;

			}

			.card {
				width: 33.3vw;
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

			}

			.content_page {
				width: 100vw;
				height: 93vh;
			}

			img {
				width: 20px;
				height: 20px;
			}

			p {
				margin: 0;
				padding: 0;
				font-size: 12px;
				color: #c3c3c3;
			}
		</style>
		<script type="text/javascript">
			$(document).ready(function() {
				// 页面初始化切换
				changeTap("#instance", "./img/tab_icon/daohanglantubiao_yingxiao_blue.png", "#1296db")
				// 页面切换
				$("#instance").click(function() {
					$("#iframePage").attr("src", "./view/InstantBoard.html");
					changeTap("#instance", "./img/tab_icon/daohanglantubiao_yingxiao_blue.png", "#1296db")
				});
				$("#movement").click(function() {
					$("#iframePage").attr("src", "./view/movementBoard.html");
					changeTap("#movement", "./img/tab_icon/daohanglantubiao_tongji_blue.png", "#1296db")
				});
				$("#record").click(function() {
					$("#iframePage").attr("src", "./view/processingRecord.html");
					changeTap("#record", "./img/tab_icon/daohanglantubiao_wuyefuwu_blue.png", "#1296db")
				});
			})
			var TagIdList = [{
				id: '#instance',
				img: "./img/tab_icon/daohanglantubiao_yingxiao.png"
			}, {
				id: '#movement',
				img: "./img/tab_icon/daohanglantubiao_tongji.png"
			}, {
				id: '#record',
				img: "./img/tab_icon/daohanglantubiao_wuyefuwu.png"
			}, ];
			// 页面切换改变样式
			function changeTap(id, img, col) {
				$(id).find("img").attr("src", img);
				$(id).find("p")[0].style.color = col;
				TagIdList.forEach(it => {
					if (it.id !== id) {
						$(it.id).find("img").attr("src", it.img);
						$(it.id).find("p")[0].style.color = '#c3c3c3';
					}
				})

			}
			// app使用
			document.addEventListener('plusready', function() {
				//console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
			});
		</script>
	</head>
	<body>
		<div class="content_page">
			<!-- 不用tab对应页面用iframe进行切换 -->
			<iframe frameborder="0" scrolling="yes" style="width:100%;height:100%" src="./view/InstantBoard.html"
				id="iframePage"></iframe>
		</div>
		<div class="buttom_nag">
			<div class="card" id="instance">
				<div> <img src="./img/tab_icon/daohanglantubiao_yingxiao.png" alt="" id="img1" /> </div>
				<p>A看板</p>
			</div>
			<div class="card" id="movement">
				<div> <img src="./img/tab_icon/daohanglantubiao_tongji.png" alt="" /> </div>
				<p>B看板</p>
			</div>
			<div class="card" id="record">
				<div> <img src="./img/tab_icon/daohanglantubiao_wuyefuwu.png" alt="" /> </div>
				<p>C统计</p>
			</div>
		</div>
	</body>
</html>

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

命不息学不止

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值