V
V
vitaly_742019-09-01 19:53:29
Vue.js
vitaly_74, 2019-09-01 19:53:29

How to include Vue in Laravel package?

Good afternoon, tell me or throw off the link (I couldn’t find it myself) how to connect vue.js in the laravel package, moreover, so that all components in vue are in the package folder (so that the package does not litter the system with its views, and that all package files are located exclusively in it, and are not scattered around the project). I would like to see the package structure itself (in folders), and in the code how to connect. thank. (Googling googled - no answers found).
Laravel tag indicated. because I'm working on this framework, and I would like to have vue.js built in there without leaving the system.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2019-09-01
@IgorPI

Vue standalone app!
It can work separately on any server in any country in the world!
There is no connection between Vue and Laravel other than the http API. Place
Vue wherever you like in the root folder at all.
For convenience, he can do this
. But I already do this.
Choose any other way.

J
jazzus, 2019-09-02
@jazzus

There will be a test component in the resources-js-components folder. You write your own on his example. You go to the app.js file and connect your component there
You run npm run watch in the console
While the process is going on, you go to the blade template and write the component there

<div id="app">
   <comp
   :users="{{json_encode($users)}}"
   ></comp>
</div>

users is a prop where you send your users. You can also fetch directly from the component using axios (google examples). And, as I was once told on the Toaster - div id="app" is better to add to the main app template (wrap everything in body). This is convenient. no need to write this div everywhere and be able to use as many components as you want on the page. If the component doesn't appear on the page, flush the browser cache and check for it in vue dev tools.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question