vue报错信息汇总

1、报错信息:Missing space before function parentheses

函数括号前缺少空格
解决:在.eslint文件的rules种添加代码:

'space-before-function-paren': 0

2、报错信息:Extra semicolon semi

使用 vue-cli 构建的项目默认的 eslint 配置要求是不能使用分号
解决:在.eslint文件的rules中添加

'semi': 0

3、报错信息: Unexpected trailing comma comma-dangle

解决:在.eslint文件的rules中添加

'comma-dangle': 0

4、报错信息:error Strings must use singlequote quotes

单引号变双引号
解决:在.eslint文件的rules中添加

'quotes': 'off'

5、报错信息:import/no-duplicates

原因是多次引用同一模块导致。
解决:在.eslint文件的rules中添加

'no-duplicate-imports': 0

6、错误信息:Newline required at end of file but not found eol-last

代码最后一行没有空一行

7、npm install vue-router --save-dev 错误提示如下

在这里插入图片描述
npm ERR! this command with --force, or --legacy-peer-deps
根据这行提示
在原本npm install 语句后面加上–force或者–legacy-peer-deps
原理:给npm 降级
原本语句:
npm install vue-router --save-dev
解决:
npm install vue-router --save-dev --legacy-peer-deps

8、vue 2 npm install vue-router --save-dev 错误信息

在这里插入图片描述
默认下载的版本太高是4的,一般搭配vue3使用,vue2上起不来
(1) 卸载当前的vue-router

npm uninstall vue-router

(2)安装指定版本的vue-router

npm install vue-router@3.1.3

9、Newline required at end of file but not found eol-last 错误信息

在这里插入图片描述最后一行需留空行

10、Missing space before function parentheses space-before-function-paren 错误信息

在这里插入图片描述
方法名和刮号之间需要有一格空格

11、- vue@2.6.11 (D:\chezaiwork\odcp-knowledge-qa\node_modules\vue\dist\vue.runtime.common.js)

vue-template-compiler@2.7.14 (D:\chezaiwork\odcp-knowledge-qa\node_modules\vue-template-compiler\package.json)
在这里插入图片描述
解决方案 找到相关文件将其删除
在这里插入图片描述

第一步:执行npm uninstall vue-template-compiler
第二步:执行npm install vue-template-compiler@报错中提示的vue的版本号

并看一下 vue得版本是否是图中得版本号
如果不是 则npm uninstall vue ; npm install vue@错误中提示得vue版本号
解决后如下
在这里插入图片描述

12、Uncaught Error: Catch all routes (“*”) must now be defined using a param with a custom regexp.

在这里插入图片描述
错误:

const routes = [
    {
        path: '*',
        name: '404',
        component: () => import('@/views/404.vue')
    }
]

解决方案:// 根据报错信息可得 必须使用正则表达式

const routes = [
    {
        // 匹配所有路径  vue2使用*   vue3使用/:pathMatch(.*)*或/:pathMatch(.*)或/:catchAll(.*)
        path: '/:pathMatch(.*)*',
        name: '404',
        component: () => import('@/views/404.vue')
    }
]

13、Object.fromEntries is not a function electron-vue

在这里插入图片描述

npm install polyfill-object.fromentries

在这里插入图片描述

// 引入
import 'polyfill-object.fromentries'

在这里插入图片描述

14、 Verion 9 of Highlight.js has reached EOL. It will no longer

在这里插入图片描述

npm install highlight.js@9.3.0

15、ReferenceError: Unknown plugin “component” specified in

在这里插入图片描述

npm install babel-plugin-component@1.1.1

15、Application entry file “dist\electron\main.js” in the “D:\r*****” does not exist. Seems like a wrong configuration. stackTrace=

在这里插入图片描述
出现错误的原因:.electron-vue\build.js文件中,代码中使用了 Multispinner ,但没有在开头引用,并且package.json文件中也没有这个依赖文件。

npm install multispinner

在这里插入图片描述
然后在.electron-vue\build.js文件中引用

const Multispinner = require('multispinner')

在这里插入图片描述

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值