首页 > 解决方案 > 了解 Storybook 在组件、故事和故事组件之间的联系

问题描述

我显然在有关故事书的文档中遗漏了一些东西,以了解正在发生的事情。如果我有如下文件结构(这恰好是一个 Vue.js 故事,但我不确定这是否重要),那么故事书可以工作

src 
  components
    MyButton.vue
stories
  Button.stories.tsx // this imports the MyButton.vue
  Button.vue
  

它可以工作,即使Button.vue一个文件!但是如果我删除或重命名Button.vue,那么故事书会抛出一个错误:

Button
ERROR in ./src/stories/Button.vue
Module build failed (from ./node_modules/vue-loader/lib/index.js):
Error: ENOENT: no such file or directory, open '<abbr path>/src/stories/Button.vue'

那么Button.stories.tsx这里是否需要一个已经建立的文件Button.vue来将信息写入该故事书使用的信息(基本上是复制组件),如果该文件丢失,那么它会给出这个错误?

标签: vue.jscomponentsstorybookfile-structure

解决方案


推荐阅读