Bak*_*k87 5 javascript vue.js vuejs2 vue-native
我完成了vue-native的安装的第一个过程,并且正在遵循“入门” Hello world教程(https://vue-native.io/getting-started.html),但是App.vue永远不会执行的App.js。如果删除,App.js则会出现错误:
“无法从“ node_modules \ expo \ AppEntry.js”解析“ ../../App””
如何解决此问题以使其正常运行,并在遇到任何问题时遵循本教程?
资料夹结构:
App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Run Code Online (Sandbox Code Playgroud)
应用程序
<template>
<view class="container">
<text class="text-color-primary">My Vue Native App</text>
</view>
</template>
<style>
.container {
background-color: white;
align-items: center;
justify-content: center;
flex: 1;
}
.text-color-primary {
color: blue;
}
</style>
Run Code Online (Sandbox Code Playgroud)
谢谢
尽管答案可能适用于某些人。还有另一种方法可以在不删除任何文件的情况下解决此问题。导航到节点模块文件夹。搜索 expo 文件夹。
打开AppEntry.js文件。它应该是这样的:
import 'expo/build/Expo.fx';
import registerRootComponent from 'expo/build/launch/registerRootComponent';
import { activateKeepAwake } from 'expo-keep-awake';
import App from '../../App'; // we will change this!
if (__DEV__) {
activateKeepAwake();
}
registerRootComponent(App);
Run Code Online (Sandbox Code Playgroud)
将Appentry.js修改为:
import 'expo/build/Expo.fx';
import registerRootComponent from 'expo/build/launch/registerRootComponent';
import { activateKeepAwake } from 'expo-keep-awake';
import App from '../../App.vue'; // Will use App.vue as the entry point
if (__DEV__) {
activateKeepAwake();
}
registerRootComponent(App);
Run Code Online (Sandbox Code Playgroud)
小智 1
以下对我有用:
首先你删除app.js这会给你一个错误,但不用担心。您必须运行该npm install命令。之后,再次运行 vue-nativenpm start
这将正常运行app.vue文件
| 归档时间: |
|
| 查看次数: |
907 次 |
| 最近记录: |