• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    Vue.js實現按鈕的動態綁定效果及實現代碼

    來源:懂視網 責編:小采 時間:2020-11-27 22:32:01
    文檔

    Vue.js實現按鈕的動態綁定效果及實現代碼

    Vue.js實現按鈕的動態綁定效果及實現代碼:實現效果: 實現代碼以及注釋: <!DOCTYPE html> <html> <head> <title>按鈕綁定</title> <meta charset=utf-8> <meta http-equiv=X-UA-Compatible conten
    推薦度:
    導讀Vue.js實現按鈕的動態綁定效果及實現代碼:實現效果: 實現代碼以及注釋: <!DOCTYPE html> <html> <head> <title>按鈕綁定</title> <meta charset=utf-8> <meta http-equiv=X-UA-Compatible conten

    實現效果:

    實現代碼以及注釋:

    <!DOCTYPE html>
    <html>
    <head>
     <title>按鈕綁定</title>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <style type="text/css">
     *{
     margin: 0;
     padding: 0;
     }
     body{
     font: 15px/1.3 'Open Sans', sans-serif;
     color: #5e5b64;
     text-align: center;
     }
     a, a:visited{
     outline: none;
     color: #3b9dc1;
     }
     a:hover{
     text-decoration: none;
     }
     section, footer, header, aside, nav{
     display: block;
     }
     /* 菜單欄 */
     nav{
     display: inline-block;
     margin: 60px auto 45px;
     background-color: #5597b4;
     box-shadow: 0 1px 1px #ccc;
     border-radius: 2px;
     }
     nav a{
     display: inline-block;
     padding: 18px 30px;
     color: #fff !important;
     font-weight: bold;
     font-size: 16px;
     text-decoration: none !important;
     line-height: 1;
     text-transform: uppercase;
     background-color: transparent;
     -webkit-transition:background-color 0.25s;
     z-index: moz-transition:background-color 0.25s;
     transition:background-color 0.25s;
     }
     nav a:first-child{
     border-radius:2px 0 0 2px;
     }
     nav a:last-child{
     border-radius:0 2px 2px 0;
     }
     nav.home .home,
     nav.projects .projects,
     nav.services .services,
     nav.contact .contact{
     background-color:#e35885;
     }
     p{
     font-size:22px;
     font-weight:bold;
     color:#7d9098;
     }
     p b{
     color:#ffffff;
     display:inline-block;
     padding:5px 10px;
     background-color:#c4d7e0;
     border-radius:2px;
     text-transform:uppercase;
     font-size:18px;
     }
     </style>
    </head>
    <body>
    <div id="main">
     <!--導航欄菜單會得到處于active的變量的值作為一個class -->
     <!-- 為了防止當我們點擊鏈接時頁面發生跳轉,我們使用prevent優化 -->
     <nav v-bind:class="active" v-on:click.prevent>
     <!-- 當一個菜單中的鏈接被點擊,我們調用定義在javaScript vue中的makeActive方法 -->
     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="home" v-on:click="makeActive('home')">Home</a>
     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="projects" v-on:click="makeActive('projects')">Projects</a>
     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="services" v-on:click="makeActive('services')">Services</a>
     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="contact" v-on:click="makeActive('contact')">Contact</a>
     </nav>
     <!-- mustache表達式將被active的值替換,它將發生任何變化它都將會自動更新-->
     <p>YOU SELECTED <b>{{active}}</b></p>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.5/vue.min.js"></script>
    <script type="text/javascript">
     // 創建一個Vue示例,并且傳遞一個可選對象
     var demo = new Vue({
     // 一個DOM元素表示我們的view模型
     el: '#main',
     // 定義屬性值,給定初始化值
     data: {
     active: 'home'
     },
     // 我們需要使用到的函數
     methods: {
     makeActive: function(item){
     // 當一個model發生變化,view會自動更新
     this.active = item;
     }
     }
     });
    </script>
    </body>
    </html>

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    Vue.js實現按鈕的動態綁定效果及實現代碼

    Vue.js實現按鈕的動態綁定效果及實現代碼:實現效果: 實現代碼以及注釋: <!DOCTYPE html> <html> <head> <title>按鈕綁定</title> <meta charset=utf-8> <meta http-equiv=X-UA-Compatible conten
    推薦度:
    標簽: 綁定 VUE 動態
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 亚洲AV无码久久精品蜜桃| 国产在线精品网址你懂的| 凹凸国产熟女精品视频app | 国产精品伦理久久久久久| 久久精品人人做人人爽97| 欧美在线精品永久免费播放| 中文字幕亚洲精品资源网| CAOPORM国产精品视频免费| 亚洲精品乱码久久久久久自慰| 国产精品热久久无码av| 久久精品一区二区| 99精品一区二区三区无码吞精| 人妻少妇精品中文字幕av蜜桃| 午夜精品久久久久久久无码| 国产啪亚洲国产精品无码 | 香蕉国产精品麻豆亚洲欧美日韩精品自拍欧美v国 | 欧美一区二区精品久久| 精品久久8x国产免费观看| 亚洲麻豆精品国偷自产在线91| 久久成人精品| 黑巨人与欧美精品一区| 国产乱子伦精品免费视频| 99久久精品免费| 91精品观看91久久久久久| 亚洲国产精品久久66| 久久青青草原精品影院| 久久精品中文字幕久久| 黑人精品videos亚洲人| 国产精品欧美亚洲韩国日本| 成人午夜精品视频在线观看| 国产第一福利精品导航| 精品精品国产高清a毛片牛牛| 国产精品99久久精品| 久久亚洲国产欧洲精品一| 日本一区二区三区精品中文字幕| 欧美精品天天操| 国产精品亚洲w码日韩中文| 精品一区二区三区免费观看 | 亚洲国产精品无码久久久不卡 | 中文字幕精品无码一区二区| 伊人久久精品影院|