Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 为什么在这个例子中有一个名为bind()的函数?_Reactjs_Bind_Aurelia - Fatal编程技术网

Reactjs 为什么在这个例子中有一个名为bind()的函数?

Reactjs 为什么在这个例子中有一个名为bind()的函数?,reactjs,bind,aurelia,Reactjs,Bind,Aurelia,为什么这里有一个名为bind()的函数?这是在应用程序生命周期中调用的Aurelia或React的回调方法吗 @noView() @inject(Element) export class Hello { @bindable foo = "!"; constructor(element) { this.element = element; } render() { ReactDom.render(<HelloTest foo={this.foo} /&

为什么这里有一个名为bind()的函数?这是在应用程序生命周期中调用的Aurelia或React的回调方法吗

@noView()
@inject(Element)
export class Hello {

  @bindable foo = "!";

  constructor(element) {
    this.element = element;
  }

  render() {
    ReactDom.render(<HelloTest foo={this.foo} />, this.element);
  }

  bind() {
    this.render();
  }

  fooChanged() {
    this.render();
  }
}
@noView()
@注入(元素)
出口类你好{
@可绑定foo=“!”;
构造函数(元素){
this.element=元素;
}
render(){
render(,this.element);
}
绑定(){
这个。render();
}
食物变化(){
这个。render();
}
}

bind
是一种奥雷利亚:

bind(bindingContext:any)
-在数据绑定引擎绑定视图时调用。绑定上下文是视图数据绑定到的实例

在本例中,由于
Hello
扩展用
@noView()
修饰(因此Aurelia不会尝试为其查找模板),因此
bind
hooked用于将React组件呈现给绑定的
this.element