require("./bootstrap");
window.Vue = require("vue").default;
Vue.component(
"example-component",
require("./components/ExampleComponent.vue").default
);
const app = new Vue({
el: "#app",
});
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Example Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body class="antialiased">
<div id="app">
<example-component />
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
CodePudding user response:
do you run npm install && npm run dev
?
CodePudding user response:
This is how I solved this problem
$ laravel new app-name
$ cd app-name
$ composer require laravel/ui
$ php artisan ui vue
$ npm install && npm run dev
<script src="{{ asset('/js/app.js') }}"></script>
<div id="app"> <component-name></component-name></div>
npm run watch