我是故事書的新手,
事實上,如果我們查看 的建構式,CustomerListComponent就會依賴于CustomerSearchComponent。
@Component({
selector: 'customer-list',
templateUrl: './customer-list.component.html',
styleUrls: ['./customer-list.component.scss']
})
export class CustomerListComponent {
constructor (
private customerSearchComponent: CustomerSearchComponent,
) {
}
...
那么在這種情況下通常會做什么?我可以告訴 storybook 加載該組件,以及它具有的任何依賴項等等嗎?我需要以CustomerSearchComponent某種方式通過模擬嗎?我很難找到這樣的案例的干凈示例,故事書檔案似乎假設組件不依賴于其他組件。
這也讓我思考 - 我不應該計劃使用故事書來呈現更大的視圖(即具有多個子組件的父級)嗎?配置起來會不會很麻煩。
PS:隨機問題 -storiesOf不推薦使用語法嗎?它不在官方檔案中,而是在網路上的教程中。
uj5u.com熱心網友回復:
根據您發布的內容,這可能會對您有所幫助,您可以嘗試一下,看看添加搜索組件是否也會呈現該組件。
此外,為了回答與 storyOf 語法相關的問題,它已被大多數支持的框架棄用,但 React Native 除外。根據維護者的反饋,React Native 將很快獲得更新,將其洗掉
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/395335.html
標籤:javascript 有角的 测试 故事书
