坦率地說,我是 React Native 的新手。我最近不得不放棄一個項目并從頭開始。我寫了這個簡單的代碼來確保一切都正常運行,令我驚訝的是拋出了一個異常。我一直在尋找解決方案很長一段時間。我將此代碼放入 Snack.expo.io,當選擇 Web 選項卡時它可以工作,但在 Android 和 IOS 上代碼不運行。如果您需要任何進一步的信息來幫助我,請告訴我。這是一個世博項目。我發現了類似的情況,有人建議刪除 npm 模塊文件夾 > 運行 npm install > npm start(在我的例子中是 yarn start)。我這樣做了,沒有任何變化。太感謝了。應用程序.jsimport 'react-native-gesture-handler';import * as React from 'react';import { View } from "react-native";import { registerRootComponent } from 'expo';function Welcome(props) { return <h1>Hello, {props.name}</h1>;}export default class App extends React.Component { render() { return ( <View> <Welcome name="Sara" /> <Welcome name="Cahal" /> <Welcome name="Edite" /> </View> ); }}registerRootComponent(App);
組件異常:文本字符串必須在 <Text> 組件中呈現
萬千封印
2023-05-25 16:31:06