zoukankan      html  css  js  c++  java
  • 05自定义组件的编写调用

    先引入再注册,即可以使用自定义组件

    <template lang="html">
      <div id="app">
        <header></header>
        <div class="tab">
          I am tab//导航区块
        </div>
        <div class="content">
          I am content//内容区块
        </div>
      </div>
    
    </template>
    
    <script type="text/ecmascript-6">
    import header from './components/header.vue';//先引入
    export default {
      components: {//在注册
        //header:herder
        header //es6支持对象的简写
      }
    }
    </script>
    
    <style lang="stylus" rel='stylesheet/stylus'>
    </style>
    
    

    header 组件

    <template lang="html">
    
        <div class="header">
          I am header//头区块
        </div>
    
      </div>
    
    </template>
    
    <script type="text/ecmascript-6">
    export default {
    
    }
    </script>
    
    <style lang="stylus" rel='stylesheet/stylus'>
    </style>
    
    
    

    然而此时还会报错,原因是用了html5中的关键字header,改为v-header就ok了

    <template lang="html">
      <div id="app">
        <v-header></v-header>
        <div class="tab">
          I am tab//导航区块
        </div>
        <div class="content">
          I am content//内容区块
        </div>
      </div>
    
    </template>
    
    <script type="text/ecmascript-6">
    import header from './components/header.vue';//先引入
    export default {
      components: {//在注册
        //header:herder
        'v-header':header 
     }
    }
    </script>
    
    <style lang="stylus" rel='stylesheet/stylus'>
    </style>
    
    

    总结:自定义组件最好以v-开头,这样既容易区分,又不会报错!

    You can change the world with your heart,even a lot of changes sometimes unless you won't geiv up....
  • 相关阅读:
    android switch控件的使用
    触摸屏校准tslib的配置文件
    matlab 函数的编写与调用
    penmount串口触摸屏加载
    FPGA保留信号的语句
    ioctl和unlock_ioctl的区别
    内核目录中增加自己的目录
    linux内核打印"BUG: scheduling while atomic
    28335外部中断
    编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
  • 原文地址:https://www.cnblogs.com/xiongwei2017/p/6643473.html
Copyright © 2011-2022 走看看