整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          JavaScript,ES6,箭頭函數,允許使用「箭頭」(=>)定義函數

          頭函數(Arrow Function)

          ES6標準新增了一種新的函數:Arrow Function(箭頭函數),使用箭頭(=>)定義函數。

          其特點是:1、如果形參只有一個,則小括號可以省略;2、函數體如果只有一條語句,則花括號可以省略,函數的返回值為該條語句的執行結果;3、箭頭函數this指向聲明時所在作用域下this的值;4、箭頭函數不能作為構造函數實例化;5、不能使用arguments。

          代碼案例

          心箭頭

          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="UTF-8">
          <title>實心箭頭</title>
          <style>
          .con{
              width: 300px;
              height: 300px;
              border: 1px solid #ccc;
              margin: 50px auto;
              background-color:#ccc;
          }
          .arrow-top{
              border-bottom: 10px solid #fff;
              border-right: 10px solid #fff;
              border-left: 10px solid #fff;
              border-top: 10px solid #ccc;
              width: 0px;
              height: 0px;
              position: relative;
              top:-40px;
              left:100px;
          }
          
          .arrow-bottom{
              border-bottom: 10px solid #fff;
              border-right: 10px solid #fff;
              border-left: 10px solid #fff;
              border-top: 10px solid #ccc;
              width: 0px;
              height: 0px;
              position: relative;
              top:-40px;
              left:100px;
          }
          </style>
          </head>
          <body>
          <div class="con">
          <div class="arrow-top"> </div>
          </div>
          </body>
          </html>



          非實心箭頭

          角形

          <!DOCTYPE html>
          <html lang="en">
          <head>
          <meta charset="UTF-8" />
          <title>三角形</title>
          <style type="text/css">
          body{
              background-color: pink;
          }
          div{
              width: 0px;
              height: 0px;
              border-top: 10px solid blue;
              border-right: 10px solid transparent;
              border-bottom: 10px solid transparent;
              border-left: 10px solid transparent;
              /* 唰(忽略不計) */
              /* border-width: 10px;
              border-style: solid;
              border-color: green orange blue pink; */
          }
          </style>
          </head>
          <body>
          <div>
          </div>
          </body>
          </html>

          箭頭

          <!DOCTYPE html>
          <html lang="en">
          <head>
          <meta charset="UTF-8" />
          <title>Document</title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
          }
          #bigBox{
              width: 0;
              height: 0;
              border-top: 200px solid black;
              border-right: 200px solid transparent;
              border-bottom: 200px solid transparent;
              border-left: 200px solid transparent;
          }
          #smallBox{
              width: 0;
              height: 0;
              border-top: 160px solid white;
              border-right: 160px solid transparent;
              border-bottom: 160px solid transparent;
              border-left: 160px solid transparent;
              position: absolute;
              left: 40px;
              top: 0;
          }
          </style>
          </head>
          <body>
          <div id="bigBox"></div>
          <div id="smallBox"></div>
          </body>
          </html>

          三角形使用案例:

          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="UTF-8">
          <title></title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
              list-style: none;
              line-height: 40px;
              cursor: pointer;
          }
          ul{
              width: 200px;
              margin: 0 auto;
              border: 1px solid #000;
          }
          h3{
              text-indent: 1em;
              background-color: dodgerblue;
              position: relative;
          }
          h3:before{
              content: "";
              width: 0;
              height: 0;
              border-top: 8px solid transparent;
              border-right: 8px solid transparent;
              border-bottom: 8px solid transparent;
              border-left: 8px solid #000;
              position: absolute;
              left: 5px;
              top: 12px;
          }
          h3.active:before{
              border-top: 8px solid #000;
              border-left: 8px solid transparent;
              left: 0px;
              top: 15px;
          }
          </style>
          </head>
          <body>
          <ul>
          <li>
          <h3>我的好友</h3>
          
          </li>
          <li>
          <h3 class="active">企業好友</h3>
          
          </li>
          <li>
          <h3>黑名單</h3>
          
          </li>
          </ul>
          </body>
          </html>

          制作箭頭

          <!DOCTYPE html>
          <html lang="en">
          <head>
          <meta charset="UTF-8" />
          <title>Document</title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
          }
          #bigBox{
              width: 0;
              height: 0;
              border-top: 200px solid black;
              border-right: 200px solid transparent;
              border-bottom: 200px solid transparent;
              border-left: 200px solid transparent;
          }
          #smallBox{
              width: 0;
              height: 0;
              border-top: 160px solid white;
              border-right: 160px solid transparent;
              border-bottom: 160px solid transparent;
              border-left: 160px solid transparent;
              position: absolute;
              left: 40px;
              top: 0;
          }
          </style>
          </head>
          <body>
          <div id="bigBox"></div>
          <div id="smallBox"></div>
          </body>
          </html>

          實例: 實心箭頭上下左右


          主站蜘蛛池模板: 无码中文字幕人妻在线一区二区三区| 国产丝袜美女一区二区三区| 成人精品视频一区二区三区| 国产精品伦一区二区三级视频| 亚洲熟妇无码一区二区三区| 国产91一区二区在线播放不卡 | 日韩精品无码Av一区二区 | 在线视频精品一区| 国产精品免费一区二区三区四区| 国产精品伦子一区二区三区| 亚洲制服中文字幕第一区| 亚洲男人的天堂一区二区| 日韩美女在线观看一区| 蜜桃臀无码内射一区二区三区| 精品人妻一区二区三区毛片| 在线免费视频一区| 亚洲国产av一区二区三区丶| 另类一区二区三区| 亚洲无线码在线一区观看 | 麻豆国产一区二区在线观看| 精品亚洲综合在线第一区| 精品日韩一区二区三区视频| 中文无码一区二区不卡αv| 亚洲AV无码一区二区乱孑伦AS| 亚洲国模精品一区| 爆乳熟妇一区二区三区霸乳| 国产AV天堂无码一区二区三区| 国产精品99精品一区二区三区| 亚洲一区电影在线观看| 国产高清视频一区三区| 亚洲日韩精品无码一区二区三区| 日韩有码一区二区| 国产福利电影一区二区三区| 武侠古典一区二区三区中文| 国产一区二区在线|播放| 暖暖免费高清日本一区二区三区| 成人精品一区二区三区电影 | 另类一区二区三区| 无码人妻久久久一区二区三区 | 亚洲片国产一区一级在线观看| 一区二区精品在线观看|