【问题标题】:React js in Aurelia js, call aurelia function在 Aurelia js 中 React js,调用 aurelia 函数
【发布时间】:2016-07-30 11:00:37
【问题描述】:

我对 react js 和 aurelia js 非常陌生,我的要求是使用 react 进行视图,使用 aurelia 进行模型/路由等。我参考了这个doc 进行安装,它运行良好。 像这样完成,这里我的视图是在 react js 中,同时单击表格中的详细信息(点图标),需要调用一个应该在 aurelia 中的函数. 我按照上面提到的文档进行编码,而不是 my-react-element.jsx 中的列表,我更改为图片中的表格样式。

【问题讨论】:

    标签: reactjs aurelia


    【解决方案1】:

    是的,我明白了。只需了解将值传递给组件(aurelia 中的 custome-component,react 中的组件)。在两者中,aurelia 和 react 它的工作原理几乎相同(如回调函数)。 代码 : react-example.js 只需声明一个要执行的函数。

    myfun(){
      alert('Hi, am in aurelia..');
    

    }

    react-example.html 使用 bind 将声明的函数设置为 custome-component。

     <react-element myfun.bind = "myfun"></react-element>
    

    react-example.js

    @bindable('myfun')
    <MyReactElement data={this.data} myfun={this.myfun}/>,
    

    my-react-element.jsx

     <p onClick = {this.try.bind(this)} >click </p>
    
     try() {
       this.props.myfun(); }
    

    注意:需要基本的 react 和 aurelia 知识并比较 doc 来修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多