vscode运行vue项目后,修改代码终端报错
问题描述
npm run serve
启动项目后,修改代码,项目会自动重新编译,但是eslint会报错。
修改的内容:
将import {Vue} from "vue-property-decorator"
的vue重新复制粘贴了一次。
问题出现的平台版本及自己尝试过哪些方法
系统:win10
工具: vscode
项目用的 vue ui图形界面自动创建的
尝试过的方法:ctrl+c强制结束然后等一会儿在npm run serve才好
相关代码
错误提示:
ERROR Failed to compile with 1 errors 14:03:51
error in ./src/components/login/Login.vue
Module Error (from ./node_modules/eslint-loader/index.js):
F:\learn\vue\vue-typescript\src\components\login\Login.vue
2:3 warning Delete `··`
prettier/prettier
3:5 warning Delete `␍⏎········`
prettier/prettier
5:1 warning Delete `····`
prettier/prettier
6:1 warning Delete `····`
prettier/prettier
7:1 warning Delete `····`
prettier/prettier
8:1 warning Replace `········<el-form·:label-position="labelPosition"·label-width="80px"·:model="loginUser">` with `····<el-form␍⏎······:label-position="labelPosition"␍⏎······label-width="80px"␍⏎······:model="loginUser"` prettier/prettier
9:5 warning Insert `>`
prettier/prettier
10:1 warning Delete `······`
prettier/prettier
11:5 warning Replace `␍⏎················<el-input·v-model="loginUser.username"></el-input>␍⏎····` with `····<el-input·v-model="loginUser.username"></el-input>`
prettier/prettier
14:7 warning Delete `······`
prettier/prettier
15:1 warning Delete `····`
prettier/prettier
16:7 warning Delete `······`
prettier/prettier
17:3 warning Delete `··␍⏎··········`
prettier/prettier
19:1 warning Replace `····␍⏎············` with `······`
prettier/prettier
21:5 warning Delete `␍⏎········`
prettier/prettier
23:3 warning Delete `··␍⏎····`
prettier/prettier
28:45 warning Insert `;`
prettier/prettier
32:1 warning Delete `··`
prettier/prettier
32:5 error Type string trivially inferred from a string literal, remove type annotation
@typescript-eslint/no-inferrable-types
33:3 warning Delete `··`
prettier/prettier
34:3 warning Replace `··public·username:·string·=·''` with `public·username:·string·=·""`
prettier/prettier
34:5 error Type string trivially inferred from a string literal, remove type annotation
@typescript-eslint/no-inferrable-types
35:1 warning Replace `····public·password:·string·=·''` with `··public·password:·string·=·""`
prettier/prettier
35:5 error Type string trivially inferred from a string literal, remove type annotation
@typescript-eslint/no-inferrable-types
✖ 24 problems (3 errors, 21 warnings)
3 errors and 21 warnings potentially fixable with the `--fix` option.
@ ./src/router/index.ts 5:0-49 14:13-18
@ ./src/main.ts
@ multi (webpack)-dev-server/client?http://192.168.124.4:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
Type checking in progress...
No type errors found
Version: typescript 3.7.5
Time: 1111ms
我的代码:
<template>
<div class="login">
<h3>Hello, this is login page</h3>
<h5>account:admin<br />password: admin</h5>
<el-form :label-position="labelPosition" label-width="80px" :model="loginUser">
<el-form-item label="用户名">
<el-input v-model="loginUser.username"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="loginUser.password"></el-input>
</el-form-item>
</el-form>
</div>
</template>
<script lang="ts">
import {Vue} from "vue-property-decorator"
import LoginEntity from "../../entity/LoginEntity";
export default class Login extends Vue {
public labelPosition: string = "left";
public loginUser: LoginEntity = new LoginEntity();
public username: string = '';
public password: string = '';
}
</script>
你期待的结果是什么?实际看到的错误信息又是什么?
期待结果:正常编译
实际错误:见错误提示代码。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修改 vue.config.js
默认是
true
,改为false