我想学习 Laravel 和 Vue.js,所以我尝试按照本教程安装两者: https ://youtu.be/WLQDpY7lOLg?t=1058 一切正常,直到 npm run dev 命令... 这些是我在 Laravel 项目终端中运行的命令(在 21:19 的教程中) 这是我运行最后 ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文简体 中文繁体 英文版本 版本,有任何建议请联系yoyou2525@163.com。
I'm new in laravel 9 and vite my old project im using laravel 7 with laravel/UI vue.js 2 for my project now im using laravel 9 and vue.js 2 and vite for my project im developed as my old style in used in laravel 7, but im facing some error IN LARAVEL 9 WITH VITE. I'm new in laravel 9 and vite my old project im using laravel 7 with laravel/UI vue.js 2 for my project now im using laravel 9 and vue.js 2 and vite for my project im developed as my old style in used in laravel 7,但我在 LARAVEL 9 WITH VITE 中遇到了一些错误。 ERROR错误
Cannot set properties of undefined (setting 'id')无法设置未定义的属性(设置“id”)
MY PROJECT CODE APP.VUE我的项目代码APP.VUE
require('./bootstrap');
import {Vue} from "vue";
import router from "./router";
window.Vue = require('vue');
const app = new Vue({
el: '#app',
router,
});
ROUTER路由器
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
// MainComponents
import Home from "./components/MainComponents/Home.vue";
const routes = [
//Admin Login
{
path: "/",
name: "Home",
component: Home,
},
];
const router = new VueRouter({
routes,
mode: "history",
});
export default router;
WELCOME.BLADE.PHP WELCOME.BLADE.PHP
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HELLO</title>
@vite('resources/css/app.css')
</head>
<body>
<div id="app">
<router-view></router-view>
</div>
@vite('resources/js/app.js')
</body>
</html>
WEB.PHP WEB.PHP
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('{any}', function () {
return view('welcome');
})->where('any', '.*');
COMPONENT零件
<template>
<div >
MAIN PAGE COMPONENT
</div>
</template>
vite.config.js vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/sass/app.scss',
'resources/js/app.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
},
},
});
First things first, it is not really practical to use require
in vite project, but if you do, you have to either use a plugin or manually work around it.首先,在 vite 项目中使用require
并不实际,但如果你这样做,你必须使用插件或手动解决它。 Does the id error comes from the vite file itself or from your code? id 错误是来自 vite 文件本身还是来自您的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.