Javascript 保存我的代码不正常工作?

Javascript 保存我的代码不正常工作?,javascript,reactjs,Javascript,Reactjs,我正在学习React JS,我的代码有问题。我写了这段代码的和平,以及每次我保存代码时代码如何被扭曲。也许我的代码管理器扩展把事情搞砸了。但我不确定。这是我的密码: class App extends React.Component { state = { articles : [ { id : 1 , title : 'article 1' , body : 'this is article 1'}, { id : 2 , title : 'article 2' , body : 't

我正在学习React JS,我的代码有问题。我写了这段代码的和平,以及每次我保存代码时代码如何被扭曲。也许我的代码管理器扩展把事情搞砸了。但我不确定。这是我的密码:

class App extends React.Component {
state = {
articles : [
  { id : 1 , title : 'article 1' , body : 'this is article 1'},
  { id : 2 , title : 'article 2' , body : 'this is article 2'},
  { id : 3 , title : 'article 3' , body : 'this is article 3'},
],
title : "soroush ghatran"
}

loadMore = () => {
  let articles = [
    { id : 4 , title : 'article 4' , body : 'this is article 4'},
    { id : 5 , title : 'article 5' , body : 'this is article 5'},
    { id : 6 , title : 'article 6' , body : 'this is article 6'},
  ]


  this.setState(prevState => {
    return {
      articles : [...prevState.articles , ...articles]
    }
   })
}

render() {
console.log(this.state)
let articleList = this.state.articles.map((article , index) => <Card key={index} title= 
 {article.title} body={article.body} />)
 
return (
  <div className="app">
    {
      articleList
    }

    <button onClick={this.loadMore}>load more</button>
  </div>
);
}
}
类应用程序扩展了React.Component{
状态={
文章:[
{id:1,标题:“第1条”,正文:“这是第1条”},
{id:2,标题:“第2条”,正文:“这是第2条”},
{id:3,标题:“第3条”,正文:“这是第3条”},
],
标题:“soroush ghatran”
}
加载更多=()=>{
让文章=[
{id:4,标题:“第4条”,正文:“这是第4条”},
{id:5,标题:“第5条”,正文:“这是第5条”},
{id:6,标题:“第6条”,正文:“这是第6条”},
]
this.setState(prevState=>{
返回{
条款:[…prevState.articles,…articles]
}
})
}
render(){
console.log(this.state)
让articleList=this.state.articles.map((文章,索引)=>)
返回(
{
标记名
}
加载更多
);
}
}

我已经检查过很多次了。我不知道我的代码是否有问题。有人能帮我吗?

这与你的代码毫无关系。请按照以下步骤操作:

  • 打开你的IDE
  • 检查您是否使用了任何可以在IDE中格式化代码的扩展
  • 如果有任何与代码格式相关的扩展,请尝试禁用这些扩展
  • 如果没有扩展,您仍然面临问题,请调整您的IDE设置。如果您提到您正在使用哪个IDE,我可以提供相应修改设置的步骤

  • 请在提问时尽量提及足够的细节,比如IDE的名称和您正在使用的扩展在这里是高度相关的。请按照这些操作。

    这可能是您的代码编辑器。你能分享你使用的代码编辑器吗?我用的是VScode@hoob_nerd谢谢你的回复。我正在使用VS代码。您是否尝试了我提到的步骤?