laravel - 你好,我使用 laravel 和 Vue js 我的作者项目它工作正常,但是这个错误?

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

  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

在应用程序中 require('./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

import Vue from 'vue' import VueRouter from 'vue-router' 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, } ,
    ]
})

最佳答案

我也遇到了这个错误。就我自己而言,我遇到了这个错误,因为我想使用 tailwind v2.0。

我认为这与 Laravel Mix v6.0 或 POSTCSS 8 有关。因为 Vue SFC 尚不支持仅支持 PostCSS 8 的插件。摘自(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

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

  • 然后npm install

  • 最后,npm run watch

  • 关于laravel - 你好,我使用 laravel 和 Vue js 我的作者项目它工作正常,但是这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64161764/

    相关文章:

    php - 使用 nohup 运行 Laravel 队列工作守护进程会导致 PDOException "General error: 1205 Lock wait timeout exceeded"

    javascript - 根据 vueJS 中的 url id 过滤表数据

    javascript - Vue - 获取没有(事件)的元素调用函数

    javascript - 如何在 Framework7 Vue 中使用身份验证

    javascript - VueJS - 如何检查匹配值的数组?

    php - Laravel 5.5 - 如何抑制 MySQL 数据库截断警告消息

    php - 装饰器和方法链

    php - Laravel 管理员编辑路线不起作用。返回 404

    vue.js - v槽:activator ="{ on }"的含义

    javascript - 循环遍历对象直到找到参数(VueJS)