【发布时间】:2021-10-17 16:55:37
【问题描述】:
每当我尝试在 React Native 中编译时,我都会收到 TypeError。 这是我正在尝试创建一个实例的类:
class GameTeam {
constructor(name, logoLocation)
{
this.name = name;
this.logoLocation = logoLocation;
};
getTeamName() {
return this.name;
}
getTeamLogoLocation() {
return this.logoLocation
}
}
我只是在创建:
const home = new GameTeam('name', 'null');
我也尝试将 const 更改为 var,但没有做任何事情。
如果它有助于解决问题,这里是主文件L
import { GameTeam } from './objects/Team'
import React from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
import { useFonts } from 'expo-font'
import { VersusScore } from './components/VersusScore';
export default function App() {
const home = new GameTeam('Tigers', 'null');
const away = new GameTeam('Raiders', 'null');
return (
<View style={mainStyles.container}>
<View style={mainStyles.topBar}>
<Image style={mainStyles.navIcon_small} source={require('./assets/Icons/Inactive/Settings_Icon.png')} />
<Text style={mainStyles.Title}>BRC</Text>
<Image style={mainStyles.navIcon_small} source={require('./assets/Icons/Inactive/Announcements_Icon.png')} />
</View>
<VersusScore homeTName={home} awayTName={away} />
</View>
);
}
【问题讨论】:
标签: javascript reactjs react-native constructor expo