详解如何创建并发布一个 vue 组件
更新时间:2018年11月08日 10:44:04 作者:wangfulin
这篇文章主要介绍了详解如何创建并发布一个vue组件,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
步骤
创建 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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
相关文章
使用Vant完成DatetimePicker 日期的选择器操作
这篇文章主要介绍了使用Vant完成DatetimePicker 日期的选择器操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-11-11


最新评论