This commit is contained in:
baileijun 2024-06-28 15:13:20 +08:00
commit 98746aa4b8
18 changed files with 396 additions and 0 deletions

26
.gitignore vendored Normal file
View File

@ -0,0 +1,26 @@
.DS_Store
node_modules
node_modules/*
/dist
/lib
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json

12
.npmignore Normal file
View File

@ -0,0 +1,12 @@
examples/
node_modules/
packages/
public/
.browserslistrc
.editorconfig
lint-staged.config.js
package-lock.json
vue.config.js
babel.config.js
src/

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# my-erp-element
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

5
babel.config.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

27
examples/index.js Normal file
View File

@ -0,0 +1,27 @@
// 导入button组件
import Button from './Button'
// 组件列表
const components = [
Button
]
// 定义 install 方法,接收 Vue 作为参数(使用 use 注册插件,那么所有的组件都会被注册)
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才能被 Vue.use() 方法安装
install,
// 以下是具体的组件列表
Button
}

13
examples/main.js Normal file
View File

@ -0,0 +1,13 @@
import Vue from 'vue'
import App from '../src/App.vue'
// 导入组件库
import myui from '../packages'
Vue.config.productionTip = false
Vue.use(myui)
new Vue({
render: h => h(App),
}).$mount('#app')

44
package.json Normal file
View File

@ -0,0 +1,44 @@
{
"name": "myErpElement",
"version": "0.1.1",
"private": false,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"lib": "vue-cli-service build --target lib packages/index.js"
},
"main": "./dist/myErpElement.umd.min.js",
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.19",
"@vue/cli-plugin-eslint": "~4.5.19",
"@vue/cli-service": "~4.5.19",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

9
packages/Button/index.js Normal file
View File

@ -0,0 +1,9 @@
import mButton from './src'
// 为组件提供 install 安装方法,供按需引入
mButton.install = function (Vue) {
Vue.component(mButton.name, mButton)
}
// 导出组件
export default mButton

View File

@ -0,0 +1,38 @@
<template>
<div class="button">
<slot name="default" :datas="datas">{{ datas.a }}</slot>
</div>
</template>
<script>
export default {
name: 'mButton',
props: {
type: String
},
data() {
return {
datas:{
a:'666',
b:'successs'
}
}
},
}
</script>
<style scoped>
.button {
width: 100px;
border: 1px solid #000;
padding: .5rem;
margin: 0 auto;
}
.button:hover {
color: aliceblue;
background-color: orange;
}
</style>

View File

@ -0,0 +1,9 @@
import mButton1 from './src'
// 为组件提供 install 安装方法,供按需引入
mButton1.install = function (Vue) {
Vue.component(mButton1.name, mButton1)
}
// 导出组件
export default mButton1

View File

@ -0,0 +1,33 @@
<template>
<div class="button">
<slot v-bind:data="name">{{ name.a }}</slot>
</div>
</template>
<script>
export default {
name: 'mButton1',
props: {
type: String
},
data() {
return {
name: { a: '777', b: '888' }
}
},
}
</script>
<style scoped>
.button {
width: 100px;
border: 1px solid #000;
padding: .5rem;
margin: 0 auto;
}
.button:hover {
color: aliceblue;
background-color: #000000;
}
</style>

29
packages/index.js Normal file
View File

@ -0,0 +1,29 @@
// 导入button组件
import mButton from './Button/src/index.vue'
import mButton1 from './Button1/src/index.vue'
// 组件列表
const components = [
mButton,mButton1
]
// 定义 install 方法,接收 Vue 作为参数(使用 use 注册插件,那么所有的组件都会被注册)
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才能被 Vue.use() 方法安装
install,
// 以下是具体的组件列表
mButton,
mButton1,
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

17
public/index.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

32
src/App.vue Normal file
View File

@ -0,0 +1,32 @@
<template>
<div id="app">
<mButton>
<template v-slot:default="{ datas }">
{{ datas.b }}
</template>
</mButton>
<!-- <mButton1/> -->
</div>
</template>
<script>
// import myComponents from '../packages'
export default {
name: 'App',
components: {
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

20
vue.config.js Normal file
View File

@ -0,0 +1,20 @@
module.exports = {
pages: {
index: {
entry: 'examples/main.js',
template: 'public/index.html',
filename: 'index.html'
}
},
// 扩展 webpack 配置,使 packages 加入编译
chainWebpack: config => {
config.module
.rule('js')
.include
.add('/packages')
.end()
.use('babel')
.loader('babel-loader')
}
}