-
What is the npm name of your library? (名称在 npm 中必须是唯一的,这里我使用的是 brian-component-lib)
-
Will this library be written in JavaScript or TypeScript? JavaScript(可以放心地选择 TypeScript,只要你清楚自己的选择)
-
Enter a location to save the library files: (项目的文件夹名称,默认为之前步骤设置的 npm 名称,所以可以直接按 enter 取默认值。)
设置完成之后,进入项目目录并执行 npm install。
cd path/to/my-component-or-lib
npm install
完成之后,选择一个编辑器来打开项目目录。
如上所述,在 /src/lib-components
文件夹中可以看到,一个示例 Vue 组件已经为我们构建好了。要查看效果,可以运行 npm run serve
命令,然后在浏览器中访问 http://localhost:8080/。
开始添加我们的自定义组件。在这个示例中,我打算模拟 freeCodeCamp 的任务介绍部分的按钮,所以在 lib-components
文件夹中新建一个名为 FccButton.vue
的 Vue 文件。