Foks
1 month ago
302
1
Vue

Failed to mount component: template or render function not defined.

Posted 1 month ago by Foks

Hello I'm trying to use Vue, and I'm quite new to it.

App.vue

<template>
  <div class="flex h-full">  
    <div class="h-full w-64 bg-green-300">
      <div class="h-16 bg-yellow-300 flex items-center justify-center">
        <p class="font-bold text-lg">our brand</p>
      </div>
    </div>
    <div class="h-full flex-1 bg-red-300">Main</div>
  </div>
</template>

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

app.js

/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');


// The following block of code may be used to automatically register your
// Vue components. It will recursively scan this directory for the Vue
// components and automatically register them with their "basename".
//  * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>

const files = require.context('./', true, /\.vue$/i)
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))


Vue.component('dashboard', require('./components/App.vue'));

// Next, we will create a fresh Vue application instance and attach it to
// the page. Then, you may begin adding components to this application
// or customize the JavaScript scaffolding to fit your unique needs.


new Vue({
    el: '#root'
});

index.blade.php

    <div id="root">
        <dashboard></dashboard>
    </div>

I just copied the ExampleCompoent.vue

Please sign in or create an account to participate in this conversation.