如何解决在故事书中设置组件参数
我已经创建了一个简单的有角度的故事,但是故事参数没有显示在组件中。 故事:
export const myStory = (args: FileExplorerComponent) => ({
component: FileExplorerComponent,template: `
<div style="position: relative">
<common-file-explorer></common-file-explorer>
<p>Przykładowe użycie Webdav</p>
</div>
`,directory: 'bip',parameters: {
directory: 'bip',},props: {
directory: 'bip',menuItems: [
{ directory: 'bip' }
],}
组件:
@Input() directory: string;
构造函数:
console.log('directory',this.directory);
显示未定义。我必须设置提供程序或构造函数参数吗?
解决方法
在您的示例中,应该不是:
template: `
<div style="position: relative">
<common-file-explorer [directory]="this.directory" ></common-file-explorer>
<p>Przykładowe użycie Webdav</p>
</div>
`,
? 或者可能
template: `
<div style="position: relative">
<common-file-explorer [directory]="this.menuItems[0].directory" ></common-file-explorer>
<p>Przykładowe użycie Webdav</p>
</div>
`,
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。