-
run
npm install --save vue
-
Add the following to your resources/js/app.js:
window.Vue = require('vue'); Vue.component('example-component', require('./components/ExampleComponent.vue').default); const app = new Vue({ el: '#app', });
-
Create an ExampleComponent.vue in the resources/js/components directory
<template> <div>Hello World.</div> </template> <script> export default { mounted() { console.log("Example component mounted"); } }; </script>
-
Add
<script src="{{ asset('js/app.js') }}" defer></script>
in the<head>
section of your layout file (resources/views/layouts/app.blade.php
) -
Add
id="app"
to<body>
or main<div>
in your layout file (resources/views/layouts/app.blade.php
) -
Add
<example-component />
to your view -
Run
npm run dev
ornpm run watch
-
Finally, open up the devtools, and in the console log you should see
Example component mounted
Last active
September 13, 2020 08:18
-
-
Save opejovic/2bc1c71b28237eb33310c06c813a54a5 to your computer and use it in GitHub Desktop.
How ti install Vue in new Laravel 8 application
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment