【问题标题】:Hello I use laravel & Vue js i author project it working fine but this error?您好,我使用 laravel 和 Vue js 我作者项目它工作正常但是这个错误?
【发布时间】:2021-01-17 13:16:44
【问题描述】:
  Module parse failed: Unexpected token (1:0)
  You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See :// webpack . js .org/concepts#loaders
  > <template>
  |     <div class="container">
  |         <div class="row justify-content-center">
   @ ./resources/js/Router.js 4:0-53 11:15-19
   @ ./resources/js/app.js
   @ multi ./resources/js/App.js ./resources/sass/app.scss

在应用程序中 需要('./bootstrap');

window.Vue = require('vue');
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import router from './Router'
 new Vue({
    el: '#app',
    router
});

在路由器js中

我正在导入 vue-router 和 vue

从 'vue' 导入 Vue 从 'vue-router' 导入 VueRouter Vue.use(VueRouter)

import User from './components/ExampleComponent.Vue'

Vue.use(VueRouter);

const router = new VueRouter({
    mode:'history',
    routes:[

        { path:'/user', component: User, } ,
        { path:'/categories', component: categories, } ,
    ]
})

【问题讨论】:

  • 您在 window 对象上实例化了 Vue 导入。然后你将路由器分配给 Vue。你试过 window.Vue.use() 吗?我不确定这是否是问题所在。
  • @JustinDuncan 是的,它在 app.js 中导入

标签: laravel vue.js vuejs2 vue-router laravel-7


【解决方案1】:

我也遇到了这个错误。在我自己的情况下,我遇到了这个错误,因为我想使用 tailwind v2.0。

我认为这与 Laravel Mix v6.0 或 POSTCSS 8 有关。因为 Vue SFC 还不能与 PostCSS 8-only 插件一起使用。取自 (https://github.com/JeffreyWay/laravel-mix/issues/2625)。

所以在我自己的情况下,我采取的步骤如下所列。

  1. 我卸载了相关的包npm uninstall tailwindcss postcss autoprefixer
  2. 然后我用兼容性版本npm install tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9重新安装了它们

查看https://tailwindcss.com/docs/installation#post-css-7-compatibility-build

  1. 我在 package.json 文件中添加了 "laravel-mix": "^5.0.1" 以将 laravel mix 从 v6.0 降级到 v5.0.1。

  2. 然后npm install

  3. 最后,npm run watch

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-10
    • 1970-01-01
    • 2021-02-07
    • 2022-06-14
    • 2019-11-12
    • 1970-01-01
    • 2021-07-26
    • 2022-10-20
    相关资源
    最近更新 更多