小编Ste*_*eve的帖子

Reactjs:使用React组件比普通函数更有优势吗?

以React.js文档中的此示例为例

var Avatar = React.createClass({
  render: function() {
    return (
      <div>
        <ProfilePic username={this.props.username} />
        <ProfileLink username={this.props.username} />
      </div>
    );
  }
});

var ProfilePic = React.createClass({
  render: function() {
    return (
      <img src={'http://graph.facebook.com/' + this.props.username + '/picture'} />
    );
  }
});

var ProfileLink = React.createClass({
  render: function() {
    return (
      <a href={'http://www.facebook.com/' + this.props.username}>
        {this.props.username}
      </a>
    );
  }
});

React.render(
  <Avatar username="pwh" />,
  document.getElementById('example')
);
Run Code Online (Sandbox Code Playgroud)

对于这样的情况,组件没有状态,如果我打算使用jsx:是否有任何缺点(性能或其他方面)只使用函数而不是创建组件?IE,将它减少到这样的东西(用ES6编写)

var { a, div, img } = React.DOM;

var Avatar = …
Run Code Online (Sandbox Code Playgroud)

reactjs

8
推荐指数
1
解决办法
370
查看次数

VSCode JSON模式文件匹配模式

在VSCode中,我试图将sjson模式添加到我拥有的项目中。我的.vscode/settings.json文件是这样的:

{
    "json.schemas": [
        {
            "fileMatch": [
                "/*.json"
            ],
            "url": "https://path/to/url.json"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

```

这可行,但是当前正在应用到项目中所有文件夹中的所有.json文件,我不需要。我希望它仅适用于根目录中的所有.json文件。我必须在该fileMatch属性中添加什么才能启用此功能?

更新资料

尝试了以下方法。这些工作,但适用于每个.json文件:

  • "/*.json"
  • "*.json"

这些根本不起作用(没有.json文件获取架构):

  • "${workspaceFolder}/*.json"
  • "${workspaceFolder}*.json"
  • "${workspaceFolder}\\*.json"
  • 以上3个没有 {}
  • 以上4同 workspaceRoot

json visual-studio-code

5
推荐指数
1
解决办法
270
查看次数

标签 统计

json ×1

reactjs ×1

visual-studio-code ×1