Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rameezisrar's avatar

[Vue warn]: Error compiling template:

I havent used vue on my project just now but i when i go to my console i get this error. I dont know why its giving me this.

<div id="spark-app" v-cloak="">
        <!-- Navigation -->
                    <!-- NavBar For Authenticated Users -->
<spark-navbar :user="user" :teams="teams" :current-team="currentTeam" :unread-announcements-count="unreadAnnouncementsCount" :unread-notifications-count="unreadNotificationsCount" inline-template="">

    <nav class="navbar navbar-light navbar-expand-md navbar-spark">
        <div class="container" v-if="user">
            <!-- Branding Image -->
            <a class="navbar-brand" href="/home">
  <img src="/img/common/grel.png">
</a>

            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div id="navbarSupportedContent" class="collapse navbar-collapse">
                <ul class="navbar-nav mr-auto">
                    <!-- Left Side Of Navbar -->

<!--
<li class="nav-item">
    <a class="nav-link" href="#">Your Link</a>
</li>
-->
                </ul>

0 likes
16 replies
rameezisrar's avatar

@bobbybouwmann the error is

Uncaught ReferenceError: Vue is not defined

i am trying to use vue but when i do anything in my view files, i get this error. How can i initilize vue in laravel 5.6 ?

bobbybouwmann's avatar

Did you include all the javascript files in your template? It looks like you're using Spark, so it should work out of the box!

ejdelmonico's avatar

Are you combining multiple nav templates from Spark? That is what I see from your short code snippet. As Bobby mentioned, it should work out of the box.

rameezisrar's avatar

@bobbybouwmann yes i am using spark. The vue should work out of the box right. But i am including a simple vue file in resource/assets/components/sample.vue file. I do have registered it app.js file but i am unable to run a vue on my view files

rameezisrar's avatar

my vue.js file includes

new Vue({
  el: '#hello',
  data: {
    message: 'Hello Vue.js!'
  }
})

then i registered this file in app.js

require('spark-bootstrap');

require('./components/bootstrap');

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

var app = new Vue({
    mixins: [require('spark')]
});

then i went into my view file, and i when i try to print that out, it doesnt show me anything. Please help me

<div id="hello">
           @{{ message }}
         </div>
rameezisrar's avatar

my console shows this

app.js?id=364c25b2b3e35b3c0b63:56942 [Vue warn]: Property or method "message" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <Home>
       <Root>

@bobbybouwmann

rameezisrar's avatar

I see nothing when i even put

<example-component></example-component>

on my view file which is provided by Laravel even after registering it on app.js

rameezisrar's avatar

@ejdelmonico Display issue. Yes I checked it with Vue tools extension for chrome. I can get the App variable and data assoicated with that but i am unable to display it on the browser(blade file).

ejdelmonico's avatar
Level 53

Did you try removing the @? Also, how did you register the component, globally in app.js or locally in another component? Additionally, I am assuming that you have run npm run dev to compile the vue components.

rameezisrar's avatar

@ejdelmonico

I am unable call a vue instance method. here is the test code

<div id="app2">
  <p> @{{ message }} </p>
  <button v-on:click="reverseMessage()">Reverse Message</button>
</div>

and in app.js

var app2 = new Vue({
  el: '#app2',
  data: {
    message: 'Hello Vue.js! What the heck'
  },
  methods: {
    reverseMessage: function () {
      alert('called')
      this.message = this.message.split('').reverse().join('')
    }
  }
})

Well i can see the 'message' data but it doesnt do anything when i click on this button which is simple. I dont know why.

damayanti123's avatar

When I have changed in profile blade file of spark admin then show error team is not defined in console how to solve the problem?

Thanks in advance

Please or to participate in this conversation.