創(chuàng)新互聯(lián)www.cdcxhl.cn八線(xiàn)動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買(mǎi)多久送多久,劃算不套路!
這篇文章主要為大家展示了Vue如何實(shí)現(xiàn)背景更換顏色,內(nèi)容簡(jiǎn)而易懂,希望大家可以學(xué)習(xí)一下,學(xué)習(xí)完之后肯定會(huì)有收獲的,下面讓小編帶大家一起來(lái)看看吧。
<!-- 分頁(yè)上下頁(yè)改變背景圖效果 --> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <link rel="stylesheet" href=""> <script type="text/javascript" src="../node_modules/vue/dist/vue.js"></script> <style type="text/css" media="screen"> .page{ list-style: none; } .page>li{ float: left; margin-left: 10px; } .page>li>a{ text-decoration: none; } .active{ color: red; text-decoration: display; } div{ width: 500px;height: 500px; } </style> </head> <body > <div id="app" v-bind:> <ul class="page"> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-on:click="decrease" >上一頁(yè)</a> </li> <li v-for="n in totalPage"> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-bind:class="n==activeNum?'active':''">{{n}}</a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" @click="increase">下一頁(yè)</a> </li> </ul> </div> <script type="text/javascript"> var exampleData={ //msg:"Hello Vue", bgCol:"#DB8623FF", totalPage:10, activeNum:3, } var app = new Vue({ el:'#app', data:exampleData, methods:{ decrease:function(){ this.activeNum==1?'':this.activeNum-=1; this.bgCol=this.getRandom(); }, increase:function(){ this.activeNum==10?'':this.activeNum+=1; this.bgCol=this.getRandom(); }, getRandom:function(){ var r=Math.floor(Math.random()*256); var g=Math.floor(Math.random()*256); var b=Math.floor(Math.random()*256); var a=Math.random().toFixed(1); return `rgba(${r},${g},$,${a})` } } }) </script> </body> </html>
名稱(chēng)欄目:Vue如何實(shí)現(xiàn)背景更換顏色-創(chuàng)新互聯(lián)
瀏覽地址:http://aaarwkj.com/article12/dohhdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、自適應(yīng)網(wǎng)站、網(wǎng)站建設(shè)、ChatGPT、微信公眾號(hào)、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容