呃呃,在写下面的代码时出现的问题,解决办法是npm install或者yarn,如果yarn报错,再npm install就可以了

下面的是携程App首页的样式,有轮播,我没有实现出来

代码如下:

  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, {Component} from 'react';
  9. import {Platform, StyleSheet, Text, View, Image,TouchableHighlight,ScrollView} from 'react-native';
  10. // var Swiper= require('react-native-swipe');
  11. // var sliderImgs = [
  12. // 'http://images3.c-ctrip.com/SBU/apph5/201505/16/app_home_ad16_640_128.png',
  13. // 'http://images3.c-ctrip.com/rk/apph5/C1/201505/app_home_ad49_640_128.png',
  14. // 'http://images3.c-ctrip.com/rk/apph5/D1/201506/app_home_ad05_640_128.jpg'
  15. // ];
  16. var BUIcon = [
  17. 'https://raw.githubusercontent.com/vczero/vczero.github.io/master/ctrip/%E6%9C%AA%E6%A0%87%E9%A2%98-1.png',
  18. 'https://raw.githubusercontent.com/vczero/vczero.github.io/master/ctrip/feiji.png',
  19. 'https://raw.githubusercontent.com/vczero/vczero.github.io/master/ctrip/lvyou.png',
  20. 'https://raw.githubusercontent.com/vczero/vczero.github.io/master/ctrip/gonglue.png'
  21. ];
  22. var Images = [
  23. 'http://webresource.c-ctrip.com/ResCRMOnline/R5/html5/images/zzz_pic_salead01.png',
  24. 'http://images3.c-ctrip.com/rk/apph5/B1/201505/app_home_ad06_310_120.jpg'
  25. ];
  26. // var sliderImgs = [
  27. // 'http://images3.c-ctrip.com/SBU/apph5/201505/16/app_home_ad16_640_128.png',
  28. // 'http://images3.c-ctrip.com/rk/apph5/C1/201505/app_home_ad49_640_128.png',
  29. // 'http://images3.c-ctrip.com/rk/apph5/D1/201506/app_home_ad05_640_128.jpg'
  30. // ];
  31. // class Slider extends Component {
  32. // rennder(){
  33. // return(
  34. // <Swiper style={styles.wrapper} showsButtons={false} autoplay={true} height={150} showsPagination={false}>
  35. // <Image style={[styles.slide,]} source={{uri: sliderImgs[0]}}></Image>
  36. // <Image style={[styles.slide,]} source={{uri: sliderImgs[1]}}></Image>
  37. // <Image style={[styles.slide,]} source={{uri: sliderImgs[2]}}></Image>
  38. // </Swiper>
  39. // );
  40. // }
  41. // }
  42. export default class App extends Component<Props> {
  43. render() {
  44. return (
  45. <ScrollView>
  46. <View style={styles.container}>
  47. <View style={[styles.sbu_view,styles.sub_red,]}>
  48. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  49. <View style={[styles.sub_con_flex, styles.sub_text]}>
  50. <Text style={[styles.font16]}>酒店</Text>
  51. </View>
  52. <View style={[styles.sub_con_flex]}>
  53. <Image style={[styles.sbu_icon_img]} source={{uri:BUIcon[0]}}></Image>
  54. </View>
  55. </View>
  56. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  57. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  58. <Text style={[styles.font16]}>海外</Text>
  59. </View>
  60. <View style={[styles.sub_con_flex, styles.sub_text]}>
  61. <Text style={[styles.font16]}>周边</Text>
  62. </View>
  63. </View>
  64. <View style={[styles.sbu_flex]}>
  65. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  66. <Text style={[styles.font16]}>团购.特惠</Text>
  67. </View>
  68. <View style={[styles.sub_con_flex, styles.sub_text]}>
  69. <Text style={[styles.font16]}>客栈.公寓</Text>
  70. </View>
  71. </View>
  72. </View>
  73. <View style={[styles.sbu_view, styles.sbu_blue]}>
  74. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  75. <View style={[styles.sub_con_flex, styles.sub_text]}>
  76. <Text style={[styles.font16]}>机票</Text>
  77. </View>
  78. <View style={[styles.sub_con_flex]}>
  79. <Image style={[styles.sbu_icon_img]} source={{uri:BUIcon[1]}}></Image>
  80. </View>
  81. </View>
  82. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  83. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  84. <Text style={[styles.font16]}>火车票</Text>
  85. </View>
  86. <View style={[styles.sub_con_flex, styles.sub_text]}>
  87. <Text style={[styles.font16]}>接收机</Text>
  88. </View>
  89. </View>
  90. <View style={[styles.sbu_flex]}>
  91. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  92. <Text style={[styles.font16]}>汽车票</Text>
  93. </View>
  94. <View style={[styles.sub_con_flex, styles.sub_text]}>
  95. <Text style={[styles.font16]}>自驾.专车</Text>
  96. </View>
  97. </View>
  98. </View>
  99. <View style={[styles.sbu_view, styles.sbu_green]}>
  100. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  101. <View style={[styles.sub_con_flex, styles.sub_text]}>
  102. <Text style={[styles.font16]}>旅游</Text>
  103. </View>
  104. <View style={[styles.sub_con_flex]}>
  105. <Image style={[styles.sbu_icon_img]} source={{uri:BUIcon[2]}}></Image>
  106. </View>
  107. </View>
  108. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  109. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  110. <Text style={[styles.font16]}>门票.玩乐</Text>
  111. </View>
  112. <View style={[styles.sub_con_flex, styles.sub_text]}>
  113. <Text style={[styles.font16]}>出境WiFi</Text>
  114. </View>
  115. </View>
  116. <View style={[styles.sbu_flex]}>
  117. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  118. <Text style={[styles.font16]}>邮轮</Text>
  119. </View>
  120. <View style={[styles.sub_con_flex, styles.sub_text]}>
  121. <Text style={[styles.font16]}>签证</Text>
  122. </View>
  123. </View>
  124. </View>
  125. <View style={[styles.sbu_view, styles.sbu_yellow]}>
  126. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  127. <View style={[styles.sub_con_flex, styles.sub_text]}>
  128. <Text style={[styles.font16]}>攻略</Text>
  129. </View>
  130. <View style={[styles.sub_con_flex]}>
  131. <Image style={[styles.sbu_icon_img]} source={{uri:BUIcon[3]}}></Image>
  132. </View>
  133. </View>
  134. <View style={[styles.sbu_flex, styles.sbu_borderRight]}>
  135. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  136. <Text style={[styles.font16]}>周末游</Text>
  137. </View>
  138. <View style={[styles.sub_con_flex, styles.sub_text]}>
  139. <Text style={[styles.font16]}>礼品卡</Text>
  140. </View>
  141. </View>
  142. <View style={[styles.sbu_flex]}>
  143. <View style={[styles.sub_con_flex, styles.sub_text, styles.sbu_borderBottom]}>
  144. <Text style={[styles.font16]}>美食.购物</Text>
  145. </View>
  146. <View style={[styles.sub_con_flex, styles.sub_text]}>
  147. <Text style={[styles.font16]}>更多</Text>
  148. </View>
  149. </View>
  150. </View>
  151. <View style={[styles.img_view]}>
  152. <View style={[styles.img_flex, {borderRightWidth:0.5}]}>
  153. <Image style={[styles.img_wh]} source={{uri:Images[0]}}></Image>
  154. </View>
  155. <View style={[styles.img_flex, {borderLeftWidth:0,}]}>
  156. <Image style={[styles.img_wh]} source={{uri:Images[1]}}></Image>
  157. </View>
  158. </View>
  159. </View>
  160. </ScrollView>
  161. );
  162. }
  163. }
  164. var styles=StyleSheet.create({
  165. container:{
  166. backgroundColor:'#F2F2F2',
  167. flex:1,
  168. },
  169. wrapper:{
  170. height:80,
  171. // resizeMode:Image.resizeMode.contain,
  172. },
  173. sbu_view:{
  174. height:84,
  175. marginLeft:5,
  176. marginRight:5,
  177. borderWidth:1,
  178. borderRadius:5,
  179. marginBottom:10,
  180. flexDirection:'row'
  181. },
  182. sub_red:{
  183. backgroundColor:'#FA6778',
  184. borderColor:'#FA6778',
  185. // marginTop:-70
  186. },
  187. sbu_blue:{
  188. backgroundColor: '#3D98FF',
  189. borderColor:'#3D98FF',
  190. },
  191. sbu_green:{
  192. backgroundColor: '#5EBE00',
  193. borderColor:'#5EBE00',
  194. },
  195. sbu_yellow:{
  196. backgroundColor: '#FC9720',
  197. borderColor:'#FC9720',
  198. },
  199. sbu_flex:{
  200. flex:1,
  201. },
  202. sbu_borderRight:{
  203. borderColor:'#fff',
  204. borderRightWidth: 0.5,
  205. },
  206. sbu_icon_img:{
  207. height:40,
  208. width:40,
  209. // resizeMode:Image.resizeMode.contain,
  210. },
  211. sub_con_flex:{
  212. flex:1,
  213. justifyContent: 'center',
  214. alignItems: 'center',
  215. },
  216. sub_text:{
  217. justifyContent:'center',
  218. },
  219. font16:{
  220. fontSize:17,
  221. color:'#FFF',
  222. fontWeight:'900',
  223. },
  224. sbu_borderBottom:{
  225. borderBottomWidth:0.5,
  226. borderBottomColor:'#fff',
  227. },
  228. img_view:{
  229. height:62,
  230. marginLeft:5,
  231. marginRight:5,
  232. flexDirection: 'row',
  233. marginBottom:20,
  234. backgroundColor:'#fff',
  235. },
  236. img_flex:{
  237. flex:1,
  238. borderWidth:1,
  239. borderColor:'#ccc',
  240. },
  241. img_wh: {
  242. height:59,
  243. borderRightWidth:0,
  244. // resizeMode:Image.resizeMode.contain,
  245. }
  246. })

Command `bundle` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.的更多相关文章

  1. react-native 引入某些低三方库时出现的Command `run-android` unrecognized,命令不识别错误

    在使用第三方库时react-native-swiper,执行 npm install react-native-swiper --save 再次运行react-native run-android时直 ...

  2. React Native 开发环境安装和配置使用报错: -bash: react-native: command not found

    [React  Native 开发环境安装和配置:-bash: react-native: command not found 报错: 前提是安装homebrew,node.js ,npm ,watc ...

  3. 关于出现Not an editor command: Bundle '**/*.vim'的解决方案【转】

    转自:https://blog.csdn.net/YHM07/article/details/49717933 操作系统: $ uname -r 2.6.32-573.7.1.el6.x86_64 $ ...

  4. Node.js log2: ERR when execute command >npm install

    1.Node.js创建项目 项目microblog创建成功,提示:cd  microblog& npm install 项目创建完成时的目录如下图所示: 2.Node.js错误 如题所言: E ...

  5. 解决React Native unable to load script from assets index.android.bundle on windows

    React Native运行的时候,经常碰到React Native unable to load script from assets index.android.bundle on windows ...

  6. Mac解决:xcode-select: error: command line tools are already installed, use "Software Update" to install updates

    1.因为node项目终端报错: No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'. No receipt for 'com ...

  7. command failed: npm install --loglevel error --registry=https://registry.npm 用vue-cli 4.0 新建项目总是报错

    昨天新买的本本,今天布环境,一安装vue-cli发现都4.0+的版本了,没管太多,就开始新建个项目感受哈,一切运行顺利,输入 "vue create app" 的时候,一切貌似进展 ...

  8. React Native: unable to load scripts from assets 'index.android.bundle' on real device

    问题:重新建了一个项目后,运行react-native run-android报: unable to load scripts from assets 'index.android.bundle' ...

  9. react native中Unable to load script from assets 'index.android.bundle'解决方案

    刚刚朋友问我,说是创建好一个项目,运行后报错:Unable to load script from assets 'index.android.bundle',以前好好的没出现这种现象,于是我找到一个 ...

随机推荐

  1. idea中 maven打包时时报错User setting file does not exist C:\Users\lenevo\.m2\setting.xml,

    第一种错误 :idea中 maven打包时时报错User setting file does not exist C:\Users\lenevo\.m2\setting.xml, 解决方案如下:将ma ...

  2. shell中的>,2>&1,&>file 解析记录

    0  表示标准输入1  表示标准输出2  表示标准错误输出>  默认为标准输出重定向,与 1> 相同2>&1  意思是把 标准错误输出 重定向到 标准输出.&> ...

  3. Mybatis-java.lang.RuntimeException: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in sqlmap/User.xml ### Cause: org.apache.ibatis.builder.B

    mappers(映射器) 使用相对于类路径的资源 如:<mapper resource="sqlmap/User.xml" /> 使用完全限定路径 如:<mapp ...

  4. React 学习(四) ---- 生命周期函数

    现在我们能修改状态,页面可以进行交互了,但是还有一种状态改变没有解决,那就是倒计时效果,时间一直在变化,组件状态也一直在改变,但我们什么都没有做,如果要实现这样的效果,需要怎么处理? 我们都知道,改变 ...

  5. BZOJ3105 新Nim游戏 【拟阵】

    题目分析: 我不知道啥是拟阵啊,但有大佬说线性基相关的都是拟阵,所以直接贪心做了. 题目代码: #include<bits/stdc++.h> using namespace std; ; ...

  6. restTemplate 发送http post请求带有文件流、参数

    String httpMethod = ""; RestTemplate restTemplate = new RestTemplate(); String args = &quo ...

  7. IDEA中Git分支未push的变更集如何合并到另一个分支

    使用rebase命令 刚开始,A分支和B分支的代码是一样的,把A分支checkout 为当前分支,并且修改了代码,进行[commit]和[push],commit成功了,但是push没有权限. 这个时 ...

  8. 【比赛】NOIP2018 货币系统

    可以发现最后的集合一定是给定集合的子集 所以就变成了裸的背包嘛,对于每个数判断它能不能被其它数表示出来,如果可以,就表示这个数是没用的,可以去掉 #include<bits/stdc++.h&g ...

  9. Qt Creator 编译测试 MQTT-C

    @2018-12-21 [小记] 创建工程步骤: a. File ---> New File or Project ---> Non-Qt Project ---> Plain C ...

  10. attr prop jquery关于获取DOM属性值的两个函数

    $('#domid').attr('acitve') $('#domid').prop('checked') // 在使用JQUERY获取DOM元素的属性时,有两个函数,attr 和 prop < ...