【发布时间】:2021-01-02 06:40:57
【问题描述】:
我是一个尝试在 Vue 中编写 POC 的菜鸟。我在 AirBNB 配置中使用 ESLint,但遇到了冲突。
这是我的 Axios 调用的错误捕获部分:
.catch((error) => {
errorMsg.value = error;
console.log('Error is ' + error);
console.log(`Error is {error}`);
});
这是我收到的 linter 错误:
50:21 error Unexpected string concatenation prefer-template
51:21 error Strings must use singlequote quotes
✖ 2 problems (2 errors, 0 warnings)
由于这两个相互冲突的规则,我似乎无法获得我想要的输出。我做错了什么?
【问题讨论】:
-
尝试将
{error}替换为${error},这是JS中字符串插值的正确语法(即不要忘记$符号)。 ESlint 可能认为是普通字符串,推荐使用单引号 -
@Riron:是的,python 把我绊倒了。把它作为一个答案,我会把它标记为正确的。谢谢!
标签: javascript vue.js eslint