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?
On pages where application components are required
import headTop from '../../components/header/head'
<head-top :head-title="loginWay? '登录':'密码登录'" goBack="true"> </head-top>
<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>
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
On pages where application components are required
The app.vue file of a certain project:
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
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