zoukankan      html  css  js  c++  java
  • vue-cli项目实操(二)

    接上一篇  vue-cli项目实操(一)

    1、新建一个组件Navbar.vue,内容如下:

    <template>  
      <div class="navbar navbar-inverse">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href=""><img id="logo" src="https://bootstrap-themes.github.io/application/assets/img/brand-white.png" alt=""></a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="active" v-for="(item,key) in items"><a :href="item">{{ key }}</a></li>
          </ul> 
        </div>
      </div>
    </template>  
    
    <script>
      export default {
        name: 'Navbar',
        data () {
          return {
            items: {
              dsf: 'dsfdsf',
              fg: 'gfhgf',
              gfh: 'dsfdsf'
            }
          }
        }
      }
    </script>
    
    <style lang="scss">
      #logo{
        85px
      }
      .navbar{
        border-radius:0;
      }
      .navbar-collapse{
          border-top:0;
          -webkit-box-shadow:none;
          box-shadow:none;
      }
      .navbar-inverse{
        background:#3097D1;
        border-color: #3097D1;
      }
      .navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a{
        color:#9d9d9d;
      }
      .navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover{
        
        background-color: #3097D1;
      }
      .navbar-inverse .navbar-toggle {
        border-color: #eee;
      }
      .navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover {
        background-color: #3097D1;
      }
    </style>

    2、index.vue内容修改为:

    <template>  
      <nav-bar></nav-bar>
    </template>
    
    <script>
      import Navbar from '@/components/Navbar'
      export default {
        name: 'Index',
        data () {
          return {
            msg: 'this is index'
          }
        },
        components: {
          'nav-bar': Navbar
        }
      }
    </script>
    
    <style lang="scss">
     
    </style>

    3、app.vue内容修改为:

    <template>
      <div id="app">
        <router-view></router-view>
      </div>
    </template>
    
    <script>
    export default {
      name: 'app'
    }
    </script>
    
    <style>
    #app {
        
    }
    </style>

    效果如图所示:

  • 相关阅读:
    JavaScript 字符串常用操作
    Redis分布式锁
    CSS布局之-水平垂直居中
    vuejs学习笔记(1)--属性,事件绑定,ajax
    Angular.js学习笔记 (一)
    几年前写的一个支持多数据库切换的设计
    bundle中vim相关快捷键的使用
    使用Bundle进行VIM插件的管理
    javascript代码在线测试
    线程池的创建
  • 原文地址:https://www.cnblogs.com/geewonii/p/7426088.html
Copyright © 2011-2022 走看看