路由跳转,有两种表现方式
1 横向
:
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="angular.js" type="text/javascript"></script>
<script src="angular-route.js" type="text/javascript"></script>
<title>路由</title>
<style type="text/css">
li {
list-style: none;
float: left;
margin: 8px;
}
</style>
<script type="text/javascript">
var app = angular.module("myApp", ["ngRoute"]);
app.config(["$routeProvider", function ($routeProvider) {
$routeProvider
.when("/index", {template: "<p><h2>首页</h2><hr><br><br><br><br><br><br><br><br><br><br><br><br></p>"})
.when("/news", {template: "<p><h2>新闻页面</h2><hr><br><br><br><br><br><br><br><br><br><br><br><br></p>"})
.when("/sport", {template: "<p><h2>体育页面</h2><hr><br><br><br><br><br><br><br><br><br><br><br><br></p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1533">
<img src="https://img.php.cn/upload/ai_manual/000/969/633/68b7a256cf84b637.png" alt="Browse AI">
</a>
<div class="aritcle_card_info">
<a href="/ai/1533">Browse AI</a>
<p>AI驱动的网页内容抓取和数据采集工具</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Browse AI">
<span>105</span>
</div>
</div>
<a href="/ai/1533" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Browse AI">
</a>
</div>
"})
.when("/game", {template: "<p><h2>游戏页面</h2><hr><br><br><br><br><br><br><br><br><br><br><br><br></p>"})
.otherwise({template: "<p><h2>404 Page Not Found!</h2><hr><br><br><br><br><br><br><br><br><br><br><br><br></p>"});
}]);
</script>
</head>
<body ng-app="myApp">
<ul>
<li><a href="#/index">首页</a></li>
<li><a href="#/news">新闻</a></li>
<li><a href="#/sport">体育</a></li>
<li><a href="#/game">游戏</a></li>
<li><a href="#/other">其他</a></li>
</ul>
<p style="clear: both"></p>
<ng-view></ng-view>
</body>
</html>2.纵向:

代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>锚点</title>
<style type="text/css">
li {
list-style: none;
float: left;
margin: 8px;
}
</style>
</head>
<body>
<ul>
<li><a href="#index">首页</a></li>
<li><a href="#news">新闻</a></li>
<li><a href="#sport">体育 </a></li>
<li><a href="#game">游戏</a></li>
</ul>
<p style="clear: both"></p>
<p>
<a id="index"></a>
<h2>首页</h2>
<hr>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
</p>
<p>
<a id="news"></a>
<h2>新闻页面</h2>
<hr>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
</p>
<p>
<a id="sport"></a>
<h2>体育页面</h2>
<hr>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
</p>
<p>
<a id="game"></a>
<h2>游戏页面</h2>
<hr>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>
</p>
</body>
</html>以上就是h5路由跳转的实现方法的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号