Javascript 响应本机导入路径快捷方式问题
我有一个RN应用程序(RN版本0.48.3),我的文件夹结构:Javascript 响应本机导入路径快捷方式问题,javascript,android,ios,react-native,Javascript,Android,Ios,React Native,我有一个RN应用程序(RN版本0.48.3),我的文件夹结构: /index.ios.js /index.android.js /app/index.js index.ios.js: import {AppRegistry} from 'react-native'; import home from './app'; AppRegistry.registerComponent('home', () => home); /app/index.js: import React, { Com
/index.ios.js
/index.android.js
/app/index.js
index.ios.js:
import {AppRegistry} from 'react-native';
import home from './app';
AppRegistry.registerComponent('home', () => home);
/app/index.js:
import React, { Component } from 'react';
import {
AppRegistry,
View
} from 'react-native';
export default class home extends Component {
render() {
return (
<View>
...
</View>
);
}
}
有人能向我解释为什么吗?路径“/app”与index.js中的路径不正确?使用camelcase尝试Home,并从类名中删除Home 瞧
import React, { Component } from 'react';
import {
AppRegistry,
View
} from 'react-native';
export default class extends Component {
render() {
return (
<View>
...
</View>
);
}
}
import {AppRegistry} from 'react-native';
import Home from './app';
AppRegistry.registerComponent('Home', () => Home);
import React,{Component}来自'React';
进口{
评估学,
看法
}从“反应本机”;
导出默认类扩展组件{
render(){
返回(
...
);
}
}
从“react native”导入{AppRegistry};
从“./app”导入主页;
AppRegistry.registerComponent('Home',()=>Home);
相同的错误。。。仅当我使用import Home from./app/index.js'更改路径时,它才起作用;这不是问题,但我想知道为什么…我的解决方案有效?放置./app时,如果要执行所做的操作,请离开一个节点以获取module.export对象中的annmye元素,在这种情况下,您已指定了名称,而导出默认值不需要名称。这里有一个例子:{Home}和export-class-Home…谢谢,但我与您的解决方案有相同的错误,似乎无法获取路径“/app”,但只能使用“/app/index.js”工作。。。
import React, { Component } from 'react';
import {
AppRegistry,
View
} from 'react-native';
export default class extends Component {
render() {
return (
<View>
...
</View>
);
}
}
import {AppRegistry} from 'react-native';
import Home from './app';
AppRegistry.registerComponent('Home', () => Home);