Larstton
Larstton

Reputation: 174

Components from Vue.js are not loaded in Laravel blade

Installed vue js with node modules for laravel 5.4 project but the components are not displayed after I run npm run watch

Installed npm, installed vue.js added vue.js file example in app.js, npm run watch - no result

blade template file

  <div id="app">
      <h1>Test</h1>
      <h2>asda</h2>
      <example-component></example-component>
  </div>

App.js

 import Vue from 'vue';

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



    //Set toaster duration
    Vue.config.productionTip = false

    new Vue({
        el: '#app',
        components: {

        }
  })

The component should be loaded after page refresh but is not. No any error messages in console.

Upvotes: 1

Views: 685

Answers (1)

makstech
makstech

Reputation: 68

  1. If you are using Webpack, you should append the require(...) with .default so it becomes require(...).default. Example in Laravel Git
  2. Make sure that you export default in your components. Example in Laravel Git

Upvotes: 1

Related Questions