关于vue告警:Strings must use singlequote

版权声明:转载请注明出处,谢谢! https://blog.csdn.net/dreamstone_xiaoqw/article/details/90453261

vscode环境开发vue-cli脚手架工程,eslint规范检查工具告警笔记

告警

告警内容:

✘  http://eslint.org/docs/rules/quotes          Strings must use singlequote
src\components\question.vue:126:18
    var body = "result=" + JSON.stringify(g_answer);
               ^

这行警告的关键信息:

Strings must use singlequote

百度翻译如下:

字符串必须使用单引号

用代码来说明,即:将

    var body = "result=" + JSON.stringify(g_answer);
               ^

修改为

    var body = 'result=' + JSON.stringify(g_answer);
               ^

即可。

官网指南

按照eslint官网的说法

Javascript 允许你用三种方式定义字符串:双引号,单引号和反勾号(在 ECMAScript 6 中)。例如:

/*eslint-env es6*/
var double = "double";
var single = 'single';
var backtick = `backtick`;    // ES6 only

只需要配置规则即可指定定义字符串的方法。

然而,小编不记得自己配置过,也没有在配置文件中找到相关配置。

暂作猜想:默认其实是使用单引号?

End

附eslint官网关于此问题的链接: https://cn.eslint.org/docs/rules/quotes

猜你喜欢

转载自blog.csdn.net/dreamstone_xiaoqw/article/details/90453261
今日推荐