关于自动添加括号,即使我不想放它,不同的程序在表现上是否有所不同,我是Reactjs的初学者,还是在Visual Studio代码和https://codesandbox.io的两个不同位置进行编码,我在其中显示了一个代码三个标记(列出),在codesandbox上的相同代码没有任何错误消息,并且没有任何问题,但是在Visual Studio代码上(我已禁用所有扩展名),它会自动添加括号,即使我删除它,也将其保存在括号中,如何节省Visual Studio代码,而无需自动添加括号:这是代码
import React, { Component } from "react";
class Counter extends Component {
state = {
count: 0,
tags: ["tag1", "tag2", "tag3"]
};
renderTags() {
if (this.state.tags.length === 0) return <p> There are no tags!</p>;
return <ul>{this.state.tags.map(tag => <li key={tag}>{tag} </li>)}</ul>;
}
render() {
return <div>{this.renderTags()}</div>;
}
}
export default Counter;
英语不是我的母语,所以很抱歉犯了错误,这是它如何更改我的代码:
renderTags() {
if (this.state.tags.length === 0) return <p> There are no tags!</p>;
return (
<ul>
{this.state.tags.map(tag => (
<li key={tag}>{tag} </li>
))}
</ul>
);
}