1、问题 $ is not definedjavascript
在使用Vs Code编写Vue应用的时候,从页面中引入jquery后,在.vue文件编写使用时,ESLint编译报错,程序运行正常。vue
错入内容以下:java
error: Unexpected console statement (no-console) at src\components\HelloWorld.vue:16:7: 14 | methods: { 15 | getOne: function() { > 16 | console.info("click"); | ^ 17 | $.get("http://www.gongjuji.net", function(data) { 18 | console.info(data); 19 | }); error: '$' is not defined (no-undef) at src\components\HelloWorld.vue:17:7: 15 | getOne: function() { 16 | console.info("click"); > 17 | $.get("http://www.gongjuji.net", function(data) { | ^ 18 | console.info(data); 19 | }); 20 | }
2、错误缘由和解决方案node
在VS Code编写Vue代码时使用ESLint编译js源代码,针对不一样的环境代码检查方式不一样。jquery
方式1.修改ESLint的检查环境,增长jquery便可。推荐json
"eslintConfig": { "root": true, "env": { "browser":true, "node": true, "jquery": true },
"eslintConfig": { "root": true, "env": { "node": true, "jquery":true },
2.设ESLint规则,忽略指定错误,例如no-console框架
"eslintConfig": { "extends": "eslint:recommended", "env": { "node": true }, "rules": { "no-console": "off" } }
更多:spa
Vue开发异常: Error: custom keyword definition is invalid: data.errors should be boolean.net
基于Vue的手机端UI框架整理eslint