2016-03-04 81 views

回答

0

我希望你没有输入

npm install <library-with-native-dependencies> --save 
-bash: library-with-native-dependencies: No such file or directory 

在你做的情况下,它应该是

npm install react-native-search-bar --save 

如果你设法手动将其链接并运行它,可以尝试设置宽度和高度for SearchBar

......... 
render(){ 
    return (<SearchBar style={styles.searchBar} ref='searchBar' placeholder='Search'/>); 
} 
......... 
const styles = StyleSheet.create({ 
    searchBar:{ 
    width: 200, 
    height: 40 
    } 
}); 
+0

我尝试手动连接是很好,但它不工作。现在我得到错误未处理JS异常:未定义不是一个对象(评估'NativeModules.RNSearchBarManager.ComponentHeight')。我很抱歉,我是新来的本地人,并得到很多错误 – Dave

+0

你可以粘贴你的代码或分享它的地方? –

+0

嘿谢谢你。我已经手动链接和使用斜坡,它是confused.I删除手动安装并再次运行命令,它现在正在工作 – Dave

0

检查模块是否存在于ProjectDirectory - > node_modules - >反应本地搜索酒吧

如果不按照以下步骤

从根目录打开的package.json

更新您的依赖关系

例如:从Github获取。

"dependencies": { 
"react": "^0.14.8", 
"react-native": "^0.25.1", 
"react-native-search-bar": "git+https://github.com/umhan35/react-native-search-bar", 
} 

OR

例:取从NPM

"dependencies": { 
"react": "^0.14.8", 
"react-native": "^0.25.1", 
"react-native-search-bar": “^2.11.0", 
} 

从终端切换到您的项目目录。

npm install 
npm start 
react-native run-ios 

那么无论你想用它你可以导入此模块。

例如:在index.ios.js

var awesomeSearchBar = require('react-native-search-bar’);