![](/img/trans.png)
[英]React-native Unable to resolve module styled-components/native
[英]React-Native undefined Unable to resolve module
我正在尝试导入我在 typescript 中制作的 class,并初始化它以通过我的视图组件传递。 但是当我尝试初始化 class 时,出现以下错误:
我的导入如下所示:
import GameModel from 'src/Rematch/Models/GameModel';
我的 GameModel class 看起来像这样:
import { QuestionModel } from "./QuestionModel";
export default class GameModel {
public questions: QuestionModel[] = [];
constructor(private id: number = 0) {
this.getData(id);
}
getData(id: number) {
console.log(id);
this.questions.push(new QuestionModel(['Goed', 'Fout', 'Nog fouter'], 'Goed', 'Dit is de eerste vraag. Als je deze goed hebt krijg je punten'));
this.questions.push(new QuestionModel(['Fout', 'Goed', 'Foutig'], 'Goed', 'Dit is de tweede vraag. Als je deze goed hebt krijg je punten'));
this.questions.push(new QuestionModel(['Fout', 'Fouter dan fout', 'Goed'], 'Goed', 'Dit is de derde vraag. Als je deze goed hebt krijg je punten'));
this.questions.push(new QuestionModel(['Dit is ook fout', 'Goed', 'Fout'], 'Goed', 'Dit is de vierde vraag. Als je deze goed hebt krijg je punten'))
}
}
打字时:
const game: GameModel = new GameModel(1)
出现错误
您的导入必须与您编写的文档相关,因此应该是这样的:
import GameModel from './Rematch/Models/GameModel';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.