詳解如何創(chuàng)建并發(fā)布一個 vue 組件
更新時間:2018年11月08日 10:44:04 作者:wangfulin
這篇文章主要介紹了詳解如何創(chuàng)建并發(fā)布一個vue組件,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
步驟
創(chuàng)建 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
寫組件
創(chuàng)建組件 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>
發(fā)布
npm publish
展示

代碼參考
vue-component-popup
參考文檔
Packaging Vue Components for npm
Vue CLI 3
vue-sfc-rollup
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用Vant完成DatetimePicker 日期的選擇器操作
這篇文章主要介紹了使用Vant完成DatetimePicker 日期的選擇器操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11
vue?select?change事件如何傳遞自定義參數(shù)
這篇文章主要介紹了vue?select?change事件如何傳遞自定義參數(shù),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-04-04
Vue3+Vite項目使用mockjs隨機(jī)模擬數(shù)據(jù)
這篇文章主要介紹了Vue3+Vite項目使用mockjs隨機(jī)模擬數(shù)據(jù),需要的朋友可以參考下2023-01-01

