标签: react-jsx

RactiveJS和JSX

RactiveJS与JSX兼容吗?

我猜一些标记不兼容.我喜欢强类型的想法,并且能够在JavaScript源代码中干净地编写模板.也许这被认为是糟糕的设计?

ractivejs react-jsx

2
推荐指数
1
解决办法
1937
查看次数

React.js + bootstrap-table仅在第一次加载时起作用,但转换会破坏表

使用http://bootstrap-table.wenzhixin.net.cn

这是我的组件包含表代码:

var Component = React.createClass({
  render: function() {
    return (
      <div className="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
            <div className="row">
                <ol className="breadcrumb">
                    <li><a href="#"><span className="glyphicon glyphicon-home"></span></a></li>
                    <li className="active">Users</li>
                </ol>
            </div><!--/.row-->

            <div className="row">
                <div className="col-lg-12">
                    <h1 className="page-header">Tables</h1>
                </div>
            </div><!--/.row-->


            <div className="row">
                <div className="col-lg-12">
                    <div className="panel panel-default">
                        <div className="panel-heading">User List</div>
                        <div className="panel-body">
                            <table ref='table' data-toggle="table" data-url='http://localhost:3000/admin/users'  data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1" data-pagination="true" data-sort-name="name" data-sort-order="desc">
                                <thead>
                                    <tr>
                          <th data-field="firstName">First Name</th>
                          <th data-field="lastName">Last Name</th>
                          <th data-field="level">Level</th>
                          <th data-field="verified">Verified</th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div> …
Run Code Online (Sandbox Code Playgroud)

javascript twitter-bootstrap reactjs react-jsx bootstrap-table

2
推荐指数
1
解决办法
4949
查看次数

通过ReactJS访问JSON中的数组

我使用ReactJS从JSON文件中获取数据

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Demo Fetch</title>
    <link rel="stylesheet" href="style.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
    <script src="js/jquery-2.1.4.min.js"></script>
</head>
<body>
    <div id="content"></div>
    <script type="text/jsx">
        var DataBlock = React.createClass({
            getInitialState:function(){
                return {data:[]};
            },
            componentDidMount:function() {
                var a=this;
                $.getJSON(this.props.url, function(data) {
                    a.setState({data:data})
                });
            },
            render: function() {
                console.log(this.state);
                return (
                        <div>
                            <h1>Sample data block</h1>
                                <h3>{this.state.data.movies[0].title}</h3>
                        </div>
                );
            }
        });
        React.render(
                <DataBlock url="small_data.json"/>,
                document.getElementById('content')
        );
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是JSON文件 small_data.json

{
  "movies": [
    {
      "abridged_cast": [
        {
          "characters": [
            "Dominic Toretto" …
Run Code Online (Sandbox Code Playgroud)

javascript arrays json reactjs react-jsx

2
推荐指数
1
解决办法
1万
查看次数

如何重定向到React Native中的页面?

this.props.navigator.push({
  component: MainView,
  passProps: {selectedTab: 'home', message: 'this is the messages'},
});
Run Code Online (Sandbox Code Playgroud)

这是重定向页面的唯一方法吗?也就是说,当条件命中时,我想渲染另一个页面,在React Native中做什么是正确的方法?

react-jsx react-native

2
推荐指数
1
解决办法
2万
查看次数

未捕获的TypeError:无法读取未定义的属性'已检查' - ReactJS

我想在ReactJS中创建一个简单的TODO列表应用程序.我对React的基础知识不是很清楚,所以我被困在这里.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>React TODO</title>
    <script src="../../build/react.js"></script>
    <script src="../../build/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script>
</head>
<body>
    <div id="example"></div>
    <script type="text/babel" lang="ja">
  var TodoList = React.createClass({

    Checked: function(e) {
    alert("Checked");
  },

  render: function() {
    var createItem = function(item) {
      return <li key={item.id}>{item.text}<input type="checkbox" onChange={this.Checked} /></li>;
    };
    return <ul>{this.props.items.map(createItem)}</ul>;
  }

});
var TodoApp = React.createClass({
  getInitialState: function() {
    return {items: [], text: ''};
  },

  onButtonClick: function(e) {
    this.setState({text: e.target.value});
  },

  handleSubmit: function(e) {
    e.preventDefault();
    var nextItems = this.state.items.concat([{text: this.state.text, id: Date.now()}]);
    var nextText = …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-jsx

2
推荐指数
1
解决办法
2384
查看次数

Redux:有必要吗?

在使用ReactJS进行开发时,是否真的需要像Redux这样的reducer?它只是设计清洁代码的一种方式吗?如果是的话,何时?

state reactjs react-jsx

2
推荐指数
1
解决办法
1032
查看次数

如何在React Native中添加自定义字体而不使用Xcode?

有没有办法在Atom编辑器中的React Native中添加自定义字体而不使用Xcode?

javascript ios react-jsx react-native

2
推荐指数
1
解决办法
2226
查看次数

如何使用Blueprint在React中呈现表

我正在尝试使用React和Blueprint UI工具包呈现一个非常简单的表.

相对于组件的文档Table非常简单,但似乎我的代码不起作用.

import React from 'react';
import ReactDOM from 'react-dom';
import * as Blueprint from '@blueprintjs/core';
import { Cell, Column, Table } from '@blueprintjs/table';

const renderCell = (rowIndex: number) => {
    return <Cell>{`$${(rowIndex * 10).toFixed(2)}`}</Cell>
};

var myTable = (
  <Table numRows={10}>
    <Column name="Dollars" renderCell={renderCell}/>
  </Table>
);

ReactDOM.render(
  myTable,
  document.getElementById('myTable')
);
Run Code Online (Sandbox Code Playgroud)

下图显示了我得到的内容.我如何解决它?

在此输入图像描述

javascript blueprint jsx reactjs react-jsx

2
推荐指数
1
解决办法
2415
查看次数

禁用jsx中的eslint错误

我在我的一个react-native组件中有以下JSX

        <TouchableOpacity onPress={this.onEnableNotifications} style={{marginHorizontal: 10}}>
          <Image source={require('../../img/ic_warning.png')} style={{tintColor: colorThemes.Blue.red}}/>
        </TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)

我收到以下ESLint错误:

'require' is not defined. (no-undef)
Run Code Online (Sandbox Code Playgroud)

我尝试过添加行{ // eslint-disable-line no-undef },Image但这会产生解析错误.我怎样才能为这一行摆脱这个错误.

reactjs eslint react-jsx react-native

2
推荐指数
2
解决办法
1903
查看次数

'?' Should be placed at the beginning of the line in ReactJS

I am working on a ReactJS project and I am getting the following error:

? should be placed at the beginning of the line operator-linebreak

Here is the snippet:

{
  index === 0 ?
    <div className='grid__row--offset--40 row'>
      <div className='small-40 columns small-centered'>
        <a className='text--white text--center text--font-size-14 button medium radius secondary' href={lang.howTiles[0].button.url}><font><font>{lang.howTiles[0].button.title}</font></font></a>
        <a href='http://localhost/slack'><img alt='Add to Slack' height='40' width='139' src='https://platform.slack-edge.com/img/add_to_slack.png' srcSet='https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x' /></a>
      </div>
    </div>
    : null
}
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-jsx

2
推荐指数
1
解决办法
970
查看次数