search

Home  >  Q&A  >  body text

javascript - How to combine vue's single file components into a page?

For example, if I now have top.vue and bottom.vue, how can they be called as the header and footer of the page in each page?

漂亮男人漂亮男人2812 days ago632

reply all(6)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 13:38:22

    On pages where application components are required

        import headTop from '../../components/header/head'
    <head-top :head-title="loginWay? '登录':'密码登录'" goBack="true">
    </head-top>

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:38:22

    The app.vue file of a certain project:

    <template>
      <p id="app">
        //在这里调用你的组件
        <TopContainer></TopContainer>
        <BHeader></BHeader>
        <BContent :rows="rows"></BContent>
        <BNavSide :options="options" v-on:change="isShowMask"></BNavSide>
        <p class="wnd-mask" ref="mask" v-show="showMask"></p>
      </p>
    </template>
    
    <script>
    
    //在这里import组件
    
    import TopContainer from 'components/common/TopContainer.vue'
    import BHeader from 'components/common/BHeader.vue'
    import BContent from 'components/content/BContent.vue'
    import BNavSide from 'components/nav/BNavSide'
    import { mapGetters } from 'vuex'
    export default {
      name: 'app',
    
      //在这里写用到的组件
    
      components: {
        TopContainer,
        BHeader,
        BContent,
        BNavSide
      }
    }
    </script>

    It is better to teach a man to fish than to teach him to fish. According to the above method, you can solve your problem

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 13:38:22

    Just register for global establishment and that’s it

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:38:22

    vue-cli generates a vue project according to the webpack-simple template and you will know how to use single file components after exploring it

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:38:22

    Create a component folder, which is broken down into header, footer and other .vue modules, and then import the reference modules respectively through import.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:38:22

    Import components and register components

    reply
    0
  • Cancelreply