网络编程
位置:首页>> 网络编程>> JavaScript>> 详解如何创建并发布一个 vue 组件

详解如何创建并发布一个 vue 组件

作者:wangfulin  发布时间:2023-07-02 16:49:08 

标签:创建,发布,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 组件

代码参考
vue-component-popup

参考文档
Packaging Vue Components for npm
Vue CLI 3
vue-sfc-rollup

来源:https://segmentfault.com/a/1190000016945983

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com