How to include common components Header and Footer in SPA Vue.js
P粉821274260
P粉821274260 2023-08-28 18:16:20
0
1
575
<p>I am creating a project in vuejs spa/I have created common components header and footer which I want to include in the main App.vue. </p> <p>I share my code structure below:</p> <ol start="2"> <li>I am sharing my file App.vue: </li> </ol> <p> <pre class="brush:html;toolbar:false;"><template> <header></header> </template> <script> import Header from './components/Header.vue' // import Footer from 'components/Footer.vue' export default { name: 'App', components: { Header, // Footer } } </script></pre> </p> <ol start="3"> <li>No idea appears in pages in Vue.js how to include header and footer together to display well in spa vuejs. What's wrong with this approach? </li> </ol></p>
P粉821274260
P粉821274260

reply all(1)
P粉488464731

header and footer are native html elements, you should use unusual names to name your components, for example name them AppHeader and AppFooter and use them like this:

<template>
  <AppHeader />
  <!-- other content-->
  <AppFooter /> 
</template>
<script>
  import {AppHeader} from './components/AppHeader.vue'
  import {AppFooter} from './components/AppFooter.vue'
  export default {
   name:'App',
   components:{ AppHeader, AppFooter}
 
  }
</script>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template