ten*_*ing 2 objective-c node.js ios reactjs react-native
我有一个非常简单的React Native项目,我正努力工作.这是一个iOS项目,它只是将一个RCTRootView添加到UIViewController中.当我从网络浏览器点击网址时,我得到:
Unable to resolve module `/src/components/HelloReact` from `/Users/myusername/Desktop/DemoReact/index.ios.js`: Directory /src/components/HelloReact doesn't exist.
Run Code Online (Sandbox Code Playgroud)
index.ios.js
'use strict';
import { AppRegistry } from 'react-native';
import HelloReact from '/src/components/HelloReact';
AppRegistry.registerComponent('HelloReact', () => HelloReact);
Run Code Online (Sandbox Code Playgroud)
HelloReact.js
import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';
export default class HelloReact extends Component {
render() {
return (
<Text style={{fontWeight: 'bold'}}>
I am bold
<Text style={{color: 'red'}}>
and red
</Text>
</Text>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我对如何解决这个问题感到茫然.我尝试了以下所有方法:
npm startnpm start --reset-cache有没有人在我的代码中看到任何错误或知道问题可能是什么?我愿意通过电子邮件或电话交谈解决这个问题.我变得绝望了.
import HelloReact from '/src/components/HelloReact'; 在绝对路径中搜索模块,而不是相对于当前(rn app)目录,因此rn找不到(因为它不存在)
将其更改为 import HelloReact from './src/components/HelloReact';
| 归档时间: |
|
| 查看次数: |
3451 次 |
| 最近记录: |