我正在使用Angular 2应用程序,尝试使用CLI创建组件时出现错误。
ng g c mycomponent
我已经尝试通过执行以下操作来重新安装cli,但似乎没有用
ng new my-project
cd my-project
ng g c my-component --m app
Your global Angular CLI version (7.2.2) is greater than your local
version (6.0.8). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
答案 0 :(得分:0)
尝试删除整个项目,然后在将组件cd创建到应用文件夹中时,键入以下内容。
checkIfDataAvailable(movies) {
if(movies.length) {
return (
<Row>
{movies.map(movie =>
<Col sm="3">
<Movie
key={movie.id}
title={movie.title}
src={`${baseImgUrl}/${movie.poster_path}`}
/>
</Col>
)}
</Row>
)
} else {
console.log('Is Loading....')
}
}
render() {
return (
<div className="Home">
<div className="Home-header">
<div className="Home-headline">
<Container fluid>
<h1 className="Home-headline__primary">Welcome To Movie Hunter Website</h1>
<p className="Home-headline__secondary">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut suscipit condimentum ligula, et ultricies lectus ligula, et ultricies lectus ligula, et ultricies lectus.</p>
<Button className="Home-headline-button">Into the Site</Button>
</Container>
</div>
</div>
<div className="Home-main">
<Container>
<h2 className="Home-main-primary">Popular Movies</h2>
{this.checkIfDataAvailable(this.state.popularMovies)}
</Container>
<Container>
<h2 className="Home-main-primary">Top Rated Movies</h2>
{this.checkIfDataAvailable(this.state.topRatedMovies)}
</Container>
</div>
</div>
)
}
肯定会创建一个组件。