javascript - How to combine vue's single file components into a page?
漂亮男人
漂亮男人 2017-05-16 13:36:22
0
6
585

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?

漂亮男人
漂亮男人

reply all(6)
左手右手慢动作

On pages where application components are required

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

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

Peter_Zhu

Just register for global establishment and that’s it

伊谢尔伦

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

伊谢尔伦

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

曾经蜡笔没有小新

Import components and register components

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template