简体   繁体   中英

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.

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM