问题描述
我是菜鸟,想用Vue编写POC。我正在将ESLint与AirBNB配置配合使用,并且发生冲突。
.catch((error) => {
errorMsg.value = error;
console.log('Error is ' + error);
console.log(`Error is {error}`);
});
这是我收到的棉短绒错误:
50:21 error Unexpected string concatenation prefer-template
51:21 error Strings must use singlequote quotes
✖ 2 problems (2 errors,0 warnings)
由于这两个冲突的规则,看来我无法获得所需的输出。我在做什么错了?
解决方法
JS中的字符串插值需要使用$
符号。
因此,您应该使用:
.catch((error) => {
errorMsg.value = error;
console.log('Error without interpolation'); // Single quotes for simple strings
console.log(`Error is ${error}`); // Template for interpolation
});