[英]I am trying to do simple routing with react-native but I am getting some error like this Failed building Javascript bundle
I created one react native project and started Routing.我创建了一个 react native 项目并开始路由。 In a project I have Pages folder, In this folder I have a Home folder in Home folder I have Home.
在一个项目中,我有 Pages 文件夹,在这个文件夹中,我在 Home 文件夹中有一个 Home 文件夹,我有 Home。 j's, and I have another folder in Pages that is About in that I have About.js.
j 的,并且我在 Pages 中有另一个文件夹,它是 About,因为我有 About.js。 These all are pages.
这些都是页面。
I have another folder that is Components, In that I have Navbar folder in that I have Navbar.js我有另一个文件夹,即 Components,其中有 Navbar 文件夹,其中有 Navbar.js
I Imported this Home to Navbar.js And I have Imported Navbar to App.js.我将此主页导入到 Navbar.js 并且我已将导航栏导入到 App.js。 Now I am getting error like this, Unable to resolve "./Pages/Home/Home" from "Components/Navbar/Navbar.js" Failed building JavaScript bundle.
现在我收到这样的错误,无法从“Components/Navbar/Navbar.js”解决“./Pages/Home/Home” 无法构建 JavaScript 捆绑包。
In the Pages folder I have a Home folder In that I have Home.js在 Pages 文件夹中,我有一个 Home 文件夹,其中有 Home.js
This Home.js这个 Home.js
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class Home extends Component {
render() {
return (
<View>
<Text>We have friends</Text>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
In the Components Folder I have a Navbar folder in that I have Navbar.js在 Components 文件夹中,我有一个 Navbar 文件夹,其中有 Navbar.js
This is Navbar.js这是 Navbar.js
import { createStackNavigator } from 'react-navigation';
import Home from './Pages/Home/Home';
const Navbar = createStackNavigator({
Home: { screen: Home },
})
export default Navbar
This is App.js这是 App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Navbar from './Components/Navbar/Navbar'
export default function App() {
return (
<Navbar></Navbar>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
I want to resolve the error what I am facing.我想解决我所面临的错误。 If you think still if I am not clear with my doubt or If you don't understand my question please put a comment.
如果您仍然认为我不清楚我的疑问或如果您不理解我的问题,请发表评论。
please try something like.../Pages/Home/Home请尝试类似.../Pages/Home/Home
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.