我已经将商店设为通用商品,但仍然说“ any”

时间:2019-07-26 21:04:05

标签: ngrx-store

我密切关注了本教程,这是我的组件类

export class AboutComponent implements OnInit {
  aboutContent: any;
  feedbackBox: any;
  feedbackComment = '';

   constructor(private store: Store<HomeState>) { }

   ngOnInit() {
    this.store.pipe(select('home')).subscribe(
      d => {
         if(d){
           this.aboutContent = d.aboutMainContent; //d is still of type 'any'
        }
     });
   }
 }

这是化简文件

import { AboutSection } from '../models/about-section';

export interface HomeState{
   aboutMainContent: AboutMainSectionState;
}

export interface AboutMainSectionState {
  aboutMainContent: AboutSection[]
}

export function reducer(state: HomeState, action): HomeState {
  switch (action.type) {
    // case 'SUBMIT_FEEDBACK':
    //     console.log('existing state: ' +JSON.stringify(state));
    //     console.log('payload: ' + action.payload);
    //     return {
    //         ...state,
    //         feedbackComment: action.payload,
    //         xwz: ''
    //     };
    default:
        return state;
 }
}

为什么 d any 类型?我想念什么吗?

感谢您的帮助

0 个答案:

没有答案