<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                1.下載組件包Vue-Awesome-Swiper并引入 [Vue-Awesome-Swiper](https://www.npmjs.com/package/vue-awesome-swiper)鏈接 ``` cd web npm i vue-awesome-swiper ``` ![](https://img.kancloud.cn/24/03/24033371782ae106bfceb55825ff0e50_1239x1049.png) ![](https://img.kancloud.cn/66/1f/661f689c7564854ac073c969c7723276_1246x855.png) 2.使用vue-swiper 在首頁組件Home.vue中使用該組件,使用方法為外層 < swiper > 內部 < swiper-slide > 。 ![](https://img.kancloud.cn/d1/68/d1686a5ec86bf074adb3a50bccac4076_1246x855.png) 此時已經可以拖動輪播了: ![](https://img.kancloud.cn/81/13/811358feb187bf3046469c4685240793_375x543.png) 3.引入廣告數據 (1)在server端創建路由 與admin端相同,在server端找到最初創建的web端接口文件index.js,編寫web端路由: ![](https://img.kancloud.cn/c5/bc/c5bc8fbec71cf93bb7247d92afd403c8_1243x855.png) 同時,在server端index.js文件中引入該web路由: ![](https://img.kancloud.cn/2a/24/2a24d78f0665e2ceccd30bc86ba37e52_1243x855.png) 測試,輸入server端鏈接和路由地址: localhost:3000/web/api/ads ![](https://img.kancloud.cn/34/97/349731046bc0ae96b59161d77f7eb635_1316x854.png) 查詢到數據,沒問題。這里我用到的是jsonview插件,大家自行下載。 ![](https://img.kancloud.cn/1f/d2/1fd2d26f4a48080a6052018141b8777a_386x352.png) (2)在web端安裝并使用axios: ``` cd web ``` ``` npm i axios ``` web端的main.js中引入axios并編寫接口: ![](https://img.kancloud.cn/e3/3e/e33e49d1cbdd262fee8590d24083db71_1243x855.png) (3)調用接口獲取數據: 到首頁頁面Home.vue,在js中調用接口: ![](https://img.kancloud.cn/36/e0/36e037d04a4abc03d80c78f73a31d3a7_1243x855.png) 成功獲取數據: ![](https://img.kancloud.cn/e5/fc/e5fcf1ce3ccd31e0da6a59a3e4e14640_1152x1084.png) 在頁面中顯示數據: ![](https://img.kancloud.cn/20/bc/20bc27dc76aa210479937bc4bd43d08a_1243x855.png) 此時圖片完成上傳,可輪播: ![](https://img.kancloud.cn/9d/a0/9da039d0a62354b0782b7888ec15c402_375x621.png) 4.為輪播廣告添加樣式,進行修飾 (1)首先,廣告是有鏈接的,我們給圖片加鏈接使其可以跳轉。 ![](https://img.kancloud.cn/a4/72/a4722b85e4ce6ebdbf906ed928d7469d_1243x855.png) 我們在后臺修改鏈接信息: ![](https://img.kancloud.cn/64/02/64021ef8ec3c9fc6d6e704379b421e17_1152x616.png) 第一個廣告鏈接到百度,第二個到我的csdn主頁。 點擊跳轉,沒問題。 (2)固定圖片大小和位置,每次設置廣告時需要固定尺寸的話就太煩了,我們把它設置成占滿寬高并居中。 style.scss: ![](https://img.kancloud.cn/16/af/16af1165787dad3142a9bae45900c440_1243x855.png) Home.vue使用sass樣式: ![](https://img.kancloud.cn/91/5c/915ce6b1728bdb4d791b5119cd2b47c9_1243x855.png) 效果: ![](https://img.kancloud.cn/5c/0a/5c0a202ffee507f92fe4881d3bf88156_375x764.png) (3)補全輪播樣式 ![](https://img.kancloud.cn/42/cb/42cb271c05ca7da4013131264a41d63a_704x1117.png) ![](https://img.kancloud.cn/cd/f5/cdf517a57a3269bf34d81a9a1eee545c_1243x978.png) 效果出現: ![](https://img.kancloud.cn/40/db/40db0600f4f21187d81551f167f8dc18_375x764.png) 但如果這個頁面出現多個swiper輪播樣式的話,就無法區分幾個樣式了,所以我們給這個輪播圖起一個獨立類名,將其掛載到此類名: ![](https://img.kancloud.cn/97/1c/971cfdfcd9b0d39c1bf9a15b25dcf225_1243x978.png) 最后,修改輪播點的位置和顏色。 當我們為輪播點span標簽加text-right類名后,發現并沒有效果: ![](https://img.kancloud.cn/ae/f8/aef8f7aff0b64fc20b5e17d59915172a_751x292.png) 是因為這個組件中有更高級的css指令,設置的是text-align: center。 ![](https://img.kancloud.cn/e1/53/e153c39e7a39a34b804fbc78cd13fe2c_1152x1084.png) 所以將我們設置的類名樣式設置為強制執行即可(!important): ![](https://img.kancloud.cn/f0/e6/f0e653173283e2be67efcdb4c7419180_1243x803.png) ![](https://img.kancloud.cn/67/20/6720f201c7abcd60b82070d7255505af_375x542.png) 修改顏色: ![](https://img.kancloud.cn/0e/3f/0e3f24f6570b7789401a25f233e8a8e0_1243x803.png) 原組件的顏色與我設置的輔助色比較相近,普通點為灰色,被選點為輔助藍色,然后我還加了個輔助色邊框: ![](https://img.kancloud.cn/bc/5f/bc5fc2f30306972158fa9e1a3ac8e867_375x542.png) 其它廣告輪播樣式大家參考包鏈接介紹。 (4)精準查詢輪播圖廣告數據 之前想一次查詢所有廣告,并按需進行廣告位置放置,但發現查詢到的json數據是按數據庫查詢排序,如果按索引查找會有變化。 所以在server后臺接口位置做出整改,以廣告位名字查找單個廣告位數據: ![](https://img.kancloud.cn/3d/d8/3dd8c94ba3077ee3ec450c6ad3c84db9_1261x803.png) web端展示數據也做一些改變: ![](https://img.kancloud.cn/20/74/2074ccf5b7363c8dd953735ad2b0d6a0_1261x1071.png) 大家可參照admin端類似方法進行封裝數據接口,同時優化自己的頁面,下一篇文章開始學習項目上線方法
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看