programing

Vue 네이티브는 항상 .vue 대신 App.js를 실행합니다.

randomtip 2022. 8. 31. 22:22
반응형

Vue 네이티브는 항상 .vue 대신 App.js를 실행합니다.

vue-timeout 설치의 첫 번째 프로세스를 만들고 "시작하기" Hello 월드 튜토리얼(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',
  },
});

App.vue

<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>

감사합니다.

하지만 어떤 사람들에게는 답이 통할 수도 있다.파일을 삭제하지 않고 이 문제를 해결할 수 있는 다른 방법이 있습니다.노드 모듈 폴더로 이동합니다.엑스포 폴더를 검색합니다.

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);

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);

다음과 같은 것이 도움이 되었습니다.
처음에 삭제했습니다.app.js이렇게 하면 오류가 발생하지만 걱정하지 마십시오.를 실행해야 합니다.npm install명령어를 입력합니다.그런 다음 vue-native를 다시 실행합니다.npm start

그러면 앱이 실행됩니다.vue 파일 정상

같은 문제가 있었다.아래가 좋습니다.

app.json에서 추가

"sourceExts": [ "js", "json", "ts", "tsx", "jsx", "vue"]

"packager Opts" 내부

"packagerOpts": { "sourceExts": [ "js", "json", "ts", "tsx", "jsx", "vue"], "config": "metro.config.js"}

https://github.com/GeekyAnts/vue-native-core/issues/117 에서 보실 수 있습니다.

웹 브라우저(실가동 준비가 되어 있지 않은 경우)에서 앱엔트리 파일을 검색하면 js > json > vue 순으로 검색됩니다.그래서 App.vue를 찾는 것은 불가능하다고 생각합니다.

Android 폰으로 보려면 단말기에서 Expo Dev Tools를 중지하고 App.js를 삭제한 후 실행하세요.npm start order또는npm run android

언급URL : https://stackoverflow.com/questions/53806021/vue-native-is-always-executing-app-js-instead-of-vue

반응형