国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

AngularJS實現的錨點樓層跳轉功能示例

2019-11-19 14:36:49
字體:
來源:轉載
供稿:網友

本文實例講述了AngularJS實現的錨點樓層跳轉功能。分享給大家供大家參考,具體如下:

<!DOCTYPE html><html ng-app="myApp">  <head>    <meta charset="UTF-8">    <title>anchor</title>    <style>      #wei div{        width:100%;        height:720px;        background: red;        color:#fff;        text-align:center;        line-height: 720px;        margin:20px;        font-size: 80px;      }      #wei ul{        position: fixed;        top:300px;        right:60px;      }      #wei ul li{        width:20px;        display:block;        height:20px;        background: gray;        color:#fff;        text-align:center;        line-height: 20px;        border-radius: 50%;        margin-bottom: 20px;        cursor: pointer;      }    </style>  </head>  <body ng-controller="show">      <div id="wei">        <div ng-repeat="attr in arr" ng-attr-id="div{{attr}}">{{attr}}</div>        <ul><!-- 定義右邊的點 -->          <li ng-repeat="attr in arr" ng-click="jump('div'+attr)">{{attr}}</li>        </ul>      </div>    <script src="angular.min.js" type="text/javascript" charset="utf-8"></script>    <script type="text/javascript">      var app = angular.module('myApp',[]);      app.controller('show',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){        $scope.arr=[1,2,3,4,5];        $scope.jump=function(id){          //console.log(id);          $location.hash(id);//添加錨點          $anchorScroll();  //重新定義服務,解決當滑動時點擊錨點無作用的bug        }      }]);    </script>  </body></html>

運行效果如下:

點擊錨點2:

點擊錨點3:

更多關于AngularJS相關內容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結》、《AngularJS入門與進階教程》及《AngularJS MVC架構總結

希望本文所述對大家AngularJS程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潞西市| 泸西县| 山阴县| 尼勒克县| 富蕴县| 乌苏市| 长子县| 衡东县| 六安市| 蓬溪县| 贵定县| 黑龙江省| 商洛市| 积石山| 西盟| 乾安县| 同江市| 娱乐| 景泰县| 北安市| 潢川县| 阜新市| 云龙县| 武功县| 黑河市| 阳谷县| 毕节市| 阳原县| 开封市| 湟源县| 邮箱| 寻甸| 筠连县| 镶黄旗| 木里| 万年县| 洛浦县| 鸡西市| 遂平县| 革吉县| 军事|