详解如何创建并发布一个 vue 组件
作者:wangfulin 时间:2023-07-02 16:49:08
步骤
创建 vue 的脚手架
npm install -g @vue/cli
vue init webpack
绑定 git 项目
cd existing_folder
git init
git remote add origin http://gitlab.alipay-inc.com/ampg/my-projec.git
git add .
git commit
git push -u origin master
写组件
创建组件 src/components/xxx.vue
例如:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
</style>
发布
npm publish
展示
代码参考
vue-component-popup
参考文档
Packaging Vue Components for npm
Vue CLI 3
vue-sfc-rollup
来源:https://segmentfault.com/a/1190000016945983
标签:创建,发布,vue组件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js 兼容多浏览器的回车和鼠标焦点事件代码(IE6/7/8,firefox,chrome)
2024-04-23 09:24:07
python+Selenium自动化测试——输入,点击操作
2023-08-09 07:20:50
![](https://img.aspxhome.com/file/2023/1/59831_0s.jpg)
python读取mat文件生成h5文件的实现
2022-08-06 08:43:28
![](https://img.aspxhome.com/file/2023/6/113106_0s.png)
SQL Server比较常见数据类型详解
2024-01-26 11:28:48
Oracle数据仓库的分层管理器解决方案开发者网络Oracle
2010-07-16 13:08:00
PyQt5 QListWidget选择多项并返回的实例
2022-12-14 07:49:25
合并ThinkPHP配置文件以消除代码冗余的实现方法
2023-11-21 11:54:31
python使用配置文件过程详解
2023-12-12 12:57:17
Python中的高级数据结构详解
2022-02-20 04:01:09
![](https://img.aspxhome.com/file/2023/4/72844_0s.jpg)
Python 获取div标签中的文字实例
2023-03-27 01:53:53
教你使用Python画棵圣诞树完整代码
2022-04-12 11:29:57
![](https://img.aspxhome.com/file/2023/3/107073_0s.jpg)
浅谈anaconda python 版本对应关系
2023-12-06 01:02:35
InnoDB数据库死锁问题处理
2024-01-19 13:30:59
TensorFlow变量管理详解
2023-11-23 07:11:18
![](https://img.aspxhome.com/file/2023/4/107204_0s.jpg)
一文让你秒懂精通pip并快速体验深度学习应用【建议收藏】
2022-07-08 22:27:56
![](https://img.aspxhome.com/file/2023/7/72927_0s.png)
css样式表实现首写字母大写
2007-10-08 12:11:00
python高阶爬虫实战分析
2023-02-04 14:11:10
解决Python httpx 运行过程中无限阻塞的问题
2023-03-26 12:17:05
MySQL语句优化的原则
2009-10-27 12:09:00
浅谈python下tiff图像的读取和保存方法
2021-11-23 04:10:08