Laravel-Vue.js应用程序在没有php artisan服务的情况下无法正常工作 [英] Laravel - Vue.js application not working without php artisan serve
问题描述
我一直在尝试使用laravel运行我的vue.js应用,而没有
I have been trying to run my vue.js app with laravel, without
php工匠服务
php artisan serve
但是严重失败了,这是我的代码:
But been seriously failing, here is my code:
package.json:
package.json:
"axios": "^0.17",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.5.7",
"vue-router": "^3.0.1"
app.js:
import './bootstrap'
import router from './routes'
const app = new Vue({
el: '#root',
router
});
routes.js:
routes.js:
import VueRouter from 'vue-router'
let routes = [
{
path: '/',
component: require('./components/site/layouts/main-page'),
children: [
{
path: '/',
component: require('./components/site/views/home')
}
]
}
];
export default new VueRouter({
mode: 'history',
linkActiveClass: 'active',
routes
});
main.page.vue:
main-page.vue:
<template>
<div>
<header></header>
<router-view></router-view>
<footer></footer>
</div>
</template>
home.vue:
<template>
<div>
<h1>Hello World!</h1>
</div>
</template>
welcome.blade.php:
welcome.blade.php:
<div id="root">
<router-view></router-view>
</div>
如果有人可以通过纠正我的错误来帮助我,我将非常有责任.
I shall be much obliged if anyone can assist me by correcting my wrong.
推荐答案
如果没有php artisan serve
,您将无法运行它,因为vue是由Laravel
处理的.如果laravel没有运行,如何运行vue app?.
You can not run it without php artisan serve
because vue is being handeled by Laravel
. If laravel is not running how you can run vue app ?.
您的第一个应用程序路径是在laravel处理的web.php中.如果不运行上述命令,则该应用程序将无法工作.
随便 如果要单独运行Vue,请使用以下命令制作单独的Vue应用:
Anyhow, If you want to run Vue separately then make separate Vue app with:
npm install vue
然后
npm install --global vue-cli
然后
vue init webpack my-project
然后
cd my-project
并与npm run dev
一起运行
它将是完全独立的Vue应用程序,不需要php artisan serve
and run with npm run dev
It will be totally separate Vue app.It will not require php artisan serve
这篇关于Laravel-Vue.js应用程序在没有php artisan服务的情况下无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!