Sounds silly, but just to be sure: did you include the main.js within your index.html?
Aug 25, 2021
12
Level 1
Vue single-file-component weirdly not showing in page
I'm not very new to Vue but this time I spent the whole day on this skeleton, no errors in browser, Webpack compiles successfully, but the "hello from dashboard" doesn't show up in the page
I think it has something to do with the render function, I've read the docs, still can't find the issue
main.js
import Vue from 'vue'
Vue.component('dashboard', require('@comp/dashboard.vue').default);
const app = require('@/App.vue').default; // this app component works fine
import "./css/app.css"
new Vue({
render: h => h(app) // this app component works fine
}).$mount('#app')
dashboard.vue
<template>
<div>
Hello from dashboard
</div>
</template>
<script>
export default {
name: "dashboard"
}
</script>
index.html
<body>
<div id="app">
<dashboard></dashboard>
</div>
</body>
this is the rendered HTML from the browser, However, "hello from dashboard" is not there :(
<body>
<div id="app">
<dashboard></dashboard>
</div>
</body>
Level 102
I dont use vue myself, but had a quick look. Instead of adding dashboard inside the html file, try adding it to the App.vue
<template>
<div>
hi from App.vue
<dashboard></dashboard>
</div>
</template>
1 like
Please or to participate in this conversation.