亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue.js template模板的使用(仿餓了么布局)

 更新時間:2018年08月13日 14:25:28   作者:至情相遇  
這篇文章主要介紹了vue.js template模板的使用,主要是模仿餓了么布局,用到了4個組件,分別是header.vue,goods.vue,ratings.vue,seller.vue,感興趣的朋友跟隨腳本之家小編一起看看實(shí)現(xiàn)代碼

使用template實(shí)現(xiàn)如下頁面(仿餓了么布局)

如上圖.使用了4個組件,分別是header.vue,goods.vue,ratings.vue,seller.vue

header.vue代碼如下

<template>
   <div class="header">
     我是header頭部
  </div>
 </template>
 <script type="text/ecmascript-6">
   export default {
  };
 </script>
<style lang="stylus" rel="stylesheet/stylus">
   .header
     color:#fff
     background:rgba(7,17,27,0.5)
     text-align:center
     height:40px
     line-height:40px
 </style>
goods.vue的代碼如下,其他兩個類似
<template>
   <div class="goods">
     我是goods組件
  </div>
 </template>
 <script type="text/ecmascript-6">
   export default {
  };
 </script>
<style lang="stylus" rel="stylesheet/stylus">
 </style>

在App.vue文件中,我們使用到了<router-link>標(biāo)簽和<router-view>

代碼如下

<template>
   <div id="app">
     <!--頭部組件-->
     <v-header></v-header>
     <div class="tab border-1px">
       <div class="tab-item">
         <router-link to="/goods/goods">商品</router-link>
       </div>
       <div class="tab-item">
         <router-link to="/ratings/ratings">評價</router-link>
       </div>
       <div class="tab-item">
         <router-link to="/seller/seller">商家</router-link>
       </div>
     </div>
     <!-- keep-alive:緩存所有的頁面,防止重復(fù)渲染DOM -->
     <keep-alive>
       <router-view></router-view>
     </keep-alive>
   </div>
 </template>
 <script type="text/ecmascript-6">
   // 引人組件
  import header from '@/components/header/header';
   export default {
     components: {
       'v-header': header
     }
   };
 </script>
<style lang="stylus" rel="stylesheet/stylus">
   @import "./common/stylus/mixin.styl";
  .tab
     display:flex
     width:100%
     height:40px
     line-height:40px
     border-1px(rgba(7,17,27,0.1))
     .tab-item
       flex:1
       text-align:center
       & > a
         display:block
         font-weight:700
         text-decoration:none
         font-size:14px
         color:rgb(77,85,93)
         &.active
           color:yellow
 </style>

 index.js中這樣寫

import Vue from 'vue';
 import VueRouter from 'vue-router';
 import VueResource from 'vue-resource';
 //引入自定義的組件
import Goods from '@/components/goods/goods';
 import Ratings from '@/components/ratings/ratings';
 import Seller from '@/components/seller/seller';
Vue.use(VueRouter);
 Vue.use(VueResource);
const routers = [{
   path:'/goods/goods',
   name:'goods',
   component:Goods
 },{
   path:'/ratings/ratings',
   name:'ratings',
   component:Ratings
 },{
   path:'/seller/seller',
   name:'seller',
   component:Seller
 }];
const router =new VueRouter({
   mode:'history', //如果不配置 mode,就會使用默認(rèn)的 hash 模式,該模式下會將路徑格式化為 #! 開頭。
   routes:routers,
   linkActiveClass : 'active' // 設(shè)置 鏈接激活時使用的 CSS 類名,默認(rèn)值: "router-link-active"
 });
 export default router;

總結(jié)

以上所述是小編給大家介紹的vue.js template模板的使用(仿餓了么布局),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 分享9個Vue的巧妙冷技巧

    分享9個Vue的巧妙冷技巧

    這篇文章主要介紹了分享9個Vue的巧妙冷技巧,文章首先通過巧用$attrs和$listeners的技巧展開,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-06-06
  • vue大文件分片上傳之simple-uploader.js的使用

    vue大文件分片上傳之simple-uploader.js的使用

    本文主要介紹了vue大文件分片上傳之simple-uploader.js的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-05-05
  • 關(guān)于全局安裝vue-cli遇到的問題及解決

    關(guān)于全局安裝vue-cli遇到的問題及解決

    這篇文章主要介紹了關(guān)于全局安裝vue-cli遇到的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • 通過命令行創(chuàng)建vue項(xiàng)目的方法

    通過命令行創(chuàng)建vue項(xiàng)目的方法

    這篇文章主要介紹了通過命令創(chuàng)建vue項(xiàng)目的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • 教你利用Vue3模仿Windows窗口

    教你利用Vue3模仿Windows窗口

    最近學(xué)習(xí)了Vue3,利用vue3做了個好玩的項(xiàng)目,所以下面這篇文章主要給大家介紹了關(guān)于如何利用Vue3模仿Windows窗口的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-04-04
  • vue過渡和animate.css結(jié)合使用詳解

    vue過渡和animate.css結(jié)合使用詳解

    本篇文章主要介紹了vue過渡和animate.css結(jié)合使用詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • 淺談Vue頁面級緩存解決方案feb-alive (下)

    淺談Vue頁面級緩存解決方案feb-alive (下)

    這篇文章主要介紹了淺談Vue頁面級緩存解決方案feb-alive(下),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 基于vue實(shí)現(xiàn)8小時帶刻度的時間軸根據(jù)當(dāng)前時間實(shí)時定位功能

    基于vue實(shí)現(xiàn)8小時帶刻度的時間軸根據(jù)當(dāng)前時間實(shí)時定位功能

    這篇文章主要介紹了基于vue實(shí)現(xiàn)8小時帶刻度的時間軸根據(jù)當(dāng)前時間實(shí)時定位功能,開始時間、結(jié)束時間可配置,根據(jù)當(dāng)前時間初始化位置,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05
  • vue頁面監(jiān)聽是否置為后臺或可見狀態(tài)問題

    vue頁面監(jiān)聽是否置為后臺或可見狀態(tài)問題

    這篇文章主要介紹了vue頁面監(jiān)聽是否置為后臺或可見狀態(tài)問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • 淺談Vue數(shù)據(jù)響應(yīng)思路之?dāng)?shù)組

    淺談Vue數(shù)據(jù)響應(yīng)思路之?dāng)?shù)組

    這篇文章主要介紹了淺談Vue數(shù)據(jù)響應(yīng)思路之?dāng)?shù)組,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11

最新評論