码迷,mamicode.com
首页 > 其他好文 > 详细

react-native decorator

时间:2017-06-27 16:24:05      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:plugin   install   ons   with   babel   component   keyboard   const   touch   

使用Decorator 首先要安装相应的Babel插件

npm install babel-plugin-transform-decorators-legacy --save,同时,需要在.babelrc中的plugins里做相应配置:

"plugins": [
  "transform-class-properties",
  "babel-plugin-transform-decorators-legacy"
]

在react-native中移除Decorator警告 jsconfig.json

{
    "compilerOptions": {
        "experimentalDecorators"true,
        "allowJs"true
    }
}
点击空白处键盘隐藏(react-native)
const dismissKeyboard = require(‘dismissKeyboard‘)
export default (WrappedComponent) => class AutoHideKeyboard extends Component {
    render() {
        return (
            <TouchableWithoutFeedback style={{flex:1}} onPress={dismissKeyboard}>
                <View style={{flex:1}}>
                    <WrappedComponent {...this.props}/>
                </View>
            </TouchableWithoutFeedback>
        )
    }
}

 

react-native decorator

标签:plugin   install   ons   with   babel   component   keyboard   const   touch   

原文地址:http://www.cnblogs.com/oldcownotGiveup/p/7085541.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!