找不到模块:错误:无法解析子组件

时间:2018-05-14 17:59:09

标签: reactjs typescript

BookStore是父组件,SearchBooks是子组件。它编译得很好,但我得到一个运行时错误,即子组件未解析。

BookStore.tsx(父组件)

import { SearchBooks, SearchParameters } from 'ClientApp/components/SearchBooks';
...
export class BookStore extends React.Component<RouteComponentProps<{}>, {}> 
...
<SearchBooks searchForBooks={this.searchForBooks} />

SearchBooks.tsx

export class SearchBooks extends React.Component<IBookSearchProps> 
...

Routes.tsx

...
<Route path='/bookStore' component={BookStore} />

文件树:

File tree

错误:

   ./ClientApp/components/BookStore.tsx中的错误       找不到模块:错误:无法解析ClientApp / components / SearchBooks&#39;在&#39; ... \ ClientApp \ components&#39;        @ ./ClientApp/components/BookStore.tsx 12:0-63        @ ./ClientApp/routes.tsx        @ ./ClientApp/boot.tsx        @ multi react-hot-loader / patch event-source-polyfill webpack-hot-middleware / client?path = __ webpack_hmr&amp; dynamicPublicPath = true ./ClientApp/boot.tsx

1 个答案:

答案 0 :(得分:0)

var configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = @"MyPath\My.config";
var config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);

var b = config.GetSectionGroup("AutoUpdate"); // This returns "AutoUpdate".

相同的目录组件,文件是SearchBooks。