I am currently learning how to build a web app using Vue.js. I have used the vue-cli (version 3.8.2), to scaffold a HelloWorld application.
I have modified the generated HelloWorld.vue
component as follows:
/path/to/vue-app/src/components/HelloWorld.vue
<template>
<div class="hello">
<b-tabs content-class="mt-3">
<b-tab title="module1" active>
<Module1/>
</b-tab>
</b-tabs>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import Module1 from './Module1.vue';
@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string;
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
/path/to/vue-app/src/components/Module1
<template>
<div class="module1">
Module1
</div>
</template>
<script>
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class Module1 extends Vue {
}
</script>
<style>
</style>
/path/to/vue-app/src/router.ts
import Vue from 'vue';
import Router from 'vue-router';
import Home from './views/Home.vue';
Vue.use(Router);
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: Home,
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ './views/About.vue'),
},
],
});
When I navigate to http://localhost:8080/
The contents of my module Module1
is not being displayed on the page.
Why is the component not being rendered (displayed), and how do I resolve this issue?