dimanche 27 janvier 2019

Cannot read property 'userId' of undefined"

I have problems about Vue JS component display in Laravel's blade. But getting this error.

[Vue warn]: Error in created hook: "TypeError: Cannot read property 'userId' of undefined"

also this

[Vue warn]: Cannot find element: .app

What I've done so far. make:auth and create new user. logged in. After that tried to display component in /home

this is home:

@extends('layouts.app')

@section('content')
<div class="container">
    <example-component></example-component>
</div>
@endsection

App.js

require('./bootstrap');

window.Vue = require('vue');

Vue.component('example-component', require('./components/ExampleComponent.vue').default);


const app = new Vue({
    el: '#app'
});

And the component

<template>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card card-default">
                    <div class="card-header">Example Component</div>

                    <div class="card-body">
                        I'm an example component.
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

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

Is there something that I missing here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire