js語法備忘(es6)

return 使用變數

var output = [];
var x = (<View><Text>test</Text></View>); //tag不能有空白,會出錯
output.push(x);

return (
  { output }
);

ref es6 用法

this._comp 為自定義的變數

ref 自定義的值,可以不用改

最後不能加 ; 分號

ref = { (ref) => this._comp = ref }

上下層使用方式

<View>
    <Node deleteMethod={ (key) => this.toDel(key) } />
</View>


toDel(key) {
    .....
}

...Node components 用法
<TouchOpacity onPress={ this.props.deleteMethod(key) }>

輸入優化方式

<TextInput
  returnKeyType="next"
  onSumbitEditing={ () => this.passwordInput.focus() }
 />

 <TextInput
   returnKeyType="go"
   ref={ (input) => this.passwordInput = input }
 />

results matching ""

    No results matching ""