[Vuejs]-Vue: Property or method “APP” is not defined on the instance but referenced during render

0👍

First of all if you want to share laravel data with vue.js I prefer to use PHP library for that and composer view of course. https://learninglaravel.net/transform-php-vars-to-javascript


To share that sort of data you have here you can choose between two directions:

  • Get your data from API (build routes with GET for specyfic data) and in VUE use AXIOS to get data from backend
  • Share with composerViews

Your approach is similar to composer views but not ideal 🙂 Read here: https://laravel.com/docs/5.7/views#view-composers more about that.

IF you choose composerViews be sure that you are serving data to a view that are only needed by this route. Don’t send everything if you are not using it.

For my, private, best option will be if you share with composerViews only required data as user info, and rest of it get with AXIOS from backend at every component with nice loader on that.


Still, if you want to find solution for your structe please look that you are matching this data to window.APP but in component you are using APP.{name}. APP is not defined for local purposes and you need to use window.APP.{name}

Leave a comment