export interface NowChannelInterface {
id: number;
name: string;
isSelected: Boolean;
}
export interface NowChannellistInterface {
nowChannelList: NowChannelInterface[];
}
const initialState: NowChannellistInterface = {
nowChannelList: [
{
id: 0,
name: 'CNN',
isSelected: true
},
{
id: 1,
name: 'BBC',
isSelected: true
},
{
id: 2,
name: 'NDTV',
isSelected: true
},
{
id: 3,
name: 'QTV',
isSelected: true
}
]
};
state: NowChannellistInterface = initialState;
const chx: any = { id: 1, name: 'BBC', isSelected: true};
cur_channel: NowChannelInterface = chx;
channels: any = state
console.log(channels);
然後初始化狀態複製到渠道, 各地申報的替代方法的任何建議是也歡迎,但請注意我必須保持上述兩個作爲接口比類能夠與觀測使用。爲什麼Javascript對象顯示如此多層次的層次結構?如何正確聲明和訪問它?
然後在控制檯時,我嘗試使用:
我不排在首位是如何被生成該層級理解,'nowChannelList> nowChannelList> nowChannelList > nowChannelList'。我只是做了'channels = initialState' – ishandutta2007
你可以在你的問題中增加額外的代碼嗎? –
你想'渠道'包含什麼?如果你不想嵌套,不要築巢。即寫'channels = initialState.nowChanelList;'。 –