清新组件库:http://ifresh-ui.yating.online/
源码地址:https://github.com/Chenyating/iFresh-ui
开发组件库准备
准备
vscode语言框架:vue,vuepress,vue-cli3,less参考框架: iview-ui,element-ui
开发定位
风格:小清醒,简洁颜色:主打绿,底白色字体:oppo字体免费商用
新建项目
全局安装
npm install -g @vue/cli 或 yarn global add @vue/cli
创建项目
vue create fresh-project
改变目录结构
src 改为packages:存放组件。index.js内容如下
import '../public/assets/style/base/fontFamly.css'
import Button
from './Button'
const components
= [
Button
]
const install = function(Vue
) {
if (install
.installed
) return
components
.map(component
=> Vue
.component(component
.name
, component
))
}
if (typeof window
!== 'undefined' && window
.Vue
) {
install(window
.Vue
)
}
export default {
install
,
Button
}
新建vue.config.js,内容如下
const path
= require('path');
module
.exports
= {
pages
: {
index
: {
entry
: 'examples/main.js',
template
: 'public/index.html',
filename
: 'index.html'
}
},
chainWebpack
: config
=> {
config
.module
.rule('js')
.include
.add('/packages')
.end()
.use('babel')
.loader('babel-loader')
.end()
},
pluginOptions
: {
'style-resources-loader': {
preProcessor
: 'less',
patterns
: [path
.resolve(__dirname
, "./public/assets/style/index.less")]
}
}
}
新建examples以vuepress目录结构创建:展示组件
.vuepress目录下新建enhanceApp.js,引入开发的组件库
import ifresh
from '../../packages/index.js'
export default ({
Vue
,
options
,
router
,
siteData
}) => {
Vue
.use(ifresh
)
}
单个组件demo
.vue文件要去name名字!
js导出
import btn
from './src'
btn
.install = function(Vue
) {
Vue
.component(btn
.name
, btn
)
}
export var Button
= btn
;