0

I used these vue js files to build my form in Larval.

When I call these files in Larval I get a blank page.

The structure of my files is as follows:

tree file show

And the contents of app.js file is as follow:

import Vue from "vue"
import App from "./components/App.vue"
import store from "./components/store"
import VeeValidate from "vee-validate"
Vue.use(VeeValidate);
import "./components/directives"
Vue.config.productionTip = false;
new Vue({
    store,
    render: h => h(App)
}).$mount("#app");

Of course, I get the below warning when I run nmp run watch's command.

WARNING in ./resources/js/app.js 5:8-19 "export 'default' (imported as 'VeeValidate') was not found in 'vee-validate' @ multi ./resources/js/app.js ./resources/sass/app.scss

My question is: How to import external vue js files to laravel project?

7
  • I solved the warning using of import * as VeeValidate from 'vee-validate'; Commented Oct 22, 2019 at 11:07
  • have you added package of vee-validate? Commented Oct 22, 2019 at 11:11
  • @JinalSomaiya Yes i added that package and the warning solved but the blank page not resolved. Commented Oct 22, 2019 at 11:12
  • @JinalSomaiya I copy the vue js files from the git and put them in the resource folder and called in the app.js. Is this right? Commented Oct 22, 2019 at 11:26
  • yes that is right but laravel how know about vuejs file? Commented Oct 22, 2019 at 11:37

3 Answers 3

2

First thing you need to include app.js to your blade file like this

<script src="{{asset('js/app.js')}}"></script>

after that if you want to use vue js components in you blade app you need to define them in your app.js like this:

Vue.component('home', require('path to your component').default);

and in your blade under div #idd add your tag <home></home>

Sign up to request clarification or add additional context in comments.

Comments

0

use src="{{ mix('js/app.js') }}"

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" value="{{ csrf_token() }}" />
    <title>VueJS CRUD Operations in Laravel</title>
    <link href="{{ mix('css/app.css') }}" type="text/css" rel="stylesheet" />
</head>

<body>
    
    <div id="app">
        
    </div>

    <script src="{{ mix('js/app.js') }}" type="text/javascript"></script>
</body>
</html>

Comments

0

I had some problem , try to use vue-router version 3 using :

npm install vue-router@3

that is working fine with me

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.