久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Vue實現(xiàn)簡單圖片切換效果

瀏覽:14日期:2022-09-28 16:34:27

本文實例為大家分享了Vue實現(xiàn)簡單圖片切換的具體代碼,供大家參考,具體內容如下

Vue實現(xiàn)簡單圖片切換效果

代碼:

<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script> <title>圖片切換</title> <style type='text/css'>*{ padding: 0; margin: 0;}#app{ position: absolute; width: 100px; height: 100px; top: 100px; left: 400px;} #left{ position: relative; top:-240px; left: -45px; font-size: 50px; } #right{ position: relative; top: -300px; left: 595px; font-size: 50px; } a{ color: black; text-decoration: none; } </style></head><body> <div id='app'><!-- 要輪詢的圖片 --> <img :src='http://m.baoyu77737.com/bcjs/imgArr[index]'/> <!-- 左箭頭 --> <a href='javascript:void(0)' @click='prev' v-show='index!=0'>《</a> <!-- 右箭頭 --> <a href='javascript:void(0)' @click='next' v-show='index<imgArr.length-1'>》</a> </div> <script>var app = new Vue({ el: '#app', data: {imgArr:[ 'img/1.jpg', 'img/2.jpg', 'img/3.jpg', 'img/4.jpg', 'img/5.jpg',],index: 0, }, methods: {prev: function(){ this.index--;},next: function(){ this.index++;}, }}) </script></body></html>

總結:

列表數(shù)據(jù)使用數(shù)組保存; v-bind指令可以設置元素屬性,如srcv-showv-if都可以切換元素的顯示狀態(tài),但頻繁切換推薦使用v-show

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 隆德县| 洛宁县| 江山市| 福贡县| 方城县| 深圳市| 商城县| 策勒县| 蓝田县| 三都| 常德市| 崇义县| 台南市| 谢通门县| 广丰县| 兴和县| 乳源| 班戈县| 深泽县| 临湘市| 阳信县| 淅川县| 邹城市| 夏河县| 卢龙县| 营口市| 邵武市| 星座| 浮梁县| 龙江县| 阳谷县| 铜山县| 宝清县| 得荣县| 寿阳县| 辽阳市| 东莞市| 洛隆县| 阳信县| 鄂温| 焉耆|