Laravel 6.1未加载Vue
我刚刚重新安装了Laravel6.1并运行了Laravel 6.1未加载Vue,laravel,Laravel,我刚刚重新安装了Laravel6.1并运行了 composer require laravel/ui php artisan ui vue npm install && npm run dev 但是在浏览器中查看我的页面时,我看到Vue组件没有显示,甚至没有加载Vue。我的DOM中有以下错误 这些是Vue未加载的原因吗?我该如何解决这些问题?url应该是http://localhost/laravel_applications/webgame/public/css/app.c
composer require laravel/ui
php artisan ui vue
npm install && npm run dev
但是在浏览器中查看我的页面时,我看到Vue组件没有显示,甚至没有加载Vue。我的DOM中有以下错误
这些是Vue未加载的原因吗?我该如何解决这些问题?url应该是http://localhost/laravel_applications/webgame/public/css/app.css
和http://localhost/laravel_applications/webgame/public/js/app.js
如何更改此设置?我正在Xammp上运行它,它位于htdocs文件夹下的/laravel_applications/webgame
。我尝试将env文件中的APP_URL更改为
APP_URL=http://localhost/laravel_applications/webgame/public
但这并不奏效
Vue安装在我的项目中,我的app.js如下所示
require('./bootstrap');
window.Vue = require('vue');
import Vue from 'vue';
// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
Vue.component('application', require('./components/application.vue').default);
const app = new Vue({
el: '#app',
});
<template>
<div>
Test
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SPA</title>
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<link rel="stylesheet" href="{{ mix('css/app.css') }}" />
<script defer src="{{ mix('js/app.js') }}"></script>
</head>
<body>
<div id="app">
<application></application>
</div>
</body>
</html>
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.13",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "7.*",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"vue-router": "^3.1.3"
}
}
我有一个components/application.vue,看起来像这样
require('./bootstrap');
window.Vue = require('vue');
import Vue from 'vue';
// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
Vue.component('application', require('./components/application.vue').default);
const app = new Vue({
el: '#app',
});
<template>
<div>
Test
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SPA</title>
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
<link rel="stylesheet" href="{{ mix('css/app.css') }}" />
<script defer src="{{ mix('js/app.js') }}"></script>
</head>
<body>
<div id="app">
<application></application>
</div>
</body>
</html>
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.13",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "7.*",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"vue-router": "^3.1.3"
}
}
这是我的混音文件
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
你不需要把
APP\u URL=http://localhost/laravel_applications/webgame/public
laravel有助手asset()
,它指向laravel的public
文件夹,因此可以通过asset()
函数加载公共目录中的任何内容
温泉