├── _config.yml
├── .gitignore
├── .travis.yml
├── src
├── index.js
└── vue-birthday-input.vue
├── .editorconfig
├── test
├── specs
│ └── vue-birthday-input.spec.js
└── karma.config.js
├── LICENSE
├── webpack.config.js
├── README.md
├── package.json
├── docs
└── index.html
└── dist
└── vue-birthday-input.min.js
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | yarn-error.log
3 | node_modules
4 | .DS_Store
5 | /test/coverage/
6 | /.vscode
7 | /.idea
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "7"
5 |
6 | before_script:
7 | - yarn install
8 |
9 | script:
10 | - yarn run lint
11 | - yarn run test
12 | - yarn run report-coverage
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import component from './vue-birthday-input.vue'
2 |
3 | const plugin = {
4 | install: Vue => {
5 | Vue.component(component.name, component)
6 | }
7 | }
8 |
9 | component.install = plugin.install
10 |
11 | export default component
12 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | tab_width = 2
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
15 |
16 | [Makefile]
17 | indent_style = tab
18 |
--------------------------------------------------------------------------------
/test/specs/vue-birthday-input.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | import Vue from 'vue'
3 | import { expect } from 'chai'
4 | import { mount } from 'avoriaz'
5 | import birthdayInput from '@/vue-birthday-input'
6 | import sinon from 'sinon'
7 |
8 | describe('vue-birthday-input.vue', () => {
9 | it('默认测试', () => {
10 | const wrapper = mount(birthdayInput, { propsData: { value: '20120101' }})
11 | expect(wrapper.data().birthday).to.equal('2012年01月01日')
12 | })
13 | it('yyyy/mm/dd', () => {
14 | const wrapper = mount(birthdayInput, { propsData: { value: '20120101', formatView: 'yyyy/mm/dd' }})
15 | expect(wrapper.data().birthday).to.equal('2012/01/01')
16 | })
17 | it('yyyy-mm-dd', () => {
18 | const wrapper = mount(birthdayInput, { propsData: { value: '20120101', formatView: 'yyyy-mm-dd' }})
19 | expect(wrapper.data().birthday).to.equal('2012-01-01')
20 | })
21 | it('format-yyyy/mm/dd', () => {
22 | const wrapper = mount(birthdayInput, { propsData: { value: '2012/01/01', formatView: 'yyyy/mm/dd', format: 'yyyy/mm/dd' }})
23 | expect(wrapper.data().birthday).to.equal('2012/01/01')
24 | })
25 | })
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Kong Fanbo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | const path = require('path')
3 | const CleanWebpackPlugin = require('clean-webpack-plugin')
4 |
5 | module.exports = {
6 | context: __dirname,
7 | resolve: {
8 | modules: [
9 | path.resolve(__dirname, 'src'),
10 | 'node_modules'
11 | ],
12 | alias: {
13 | 'vue$': 'vue/dist/vue.esm.js'
14 | },
15 | extensions: ['.js', '.json', '.vue']
16 | },
17 | entry: './src/index.js',
18 | externals: {
19 | 'moment': {
20 | commonjs: 'moment',
21 | commonjs2: 'moment',
22 | amd: 'moment',
23 | root: 'moment'
24 | }
25 | },
26 | output: {
27 | path: path.resolve(__dirname, 'dist'),
28 | filename: "vue-birthday-input.min.js",
29 | library: 'VueBirthdayInput',
30 | libraryTarget: 'umd',
31 | umdNamedDefine: true
32 | },
33 | module: {
34 | rules: [
35 | {
36 | test: /\.vue$/,
37 | loader: 'vue-loader'
38 | },
39 | {
40 | test: /\.js$/,
41 | loader: 'babel-loader',
42 | exclude: path.resolve(__dirname, 'node_modules')
43 | }
44 | ]
45 | },
46 | plugins: [
47 | new CleanWebpackPlugin(['./dist'])
48 | ],
49 | devtool: false,
50 | performance: {
51 | hints: false
52 | }
53 | }
--------------------------------------------------------------------------------
/test/karma.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node, mocha */
2 |
3 | var path = require('path')
4 |
5 | module.exports = config => {
6 | config.set({
7 | browsers: ['PhantomJS'],
8 | frameworks: ['mocha', 'sinon-chai'],
9 | reporters: ['spec', 'coverage'],
10 | files: ['specs/*.spec.js'],
11 | preprocessors: {
12 | './specs/*.spec.js': ['webpack', 'sourcemap']
13 | },
14 | webpack: {
15 | devtool: '#inline-source-map',
16 | resolve: {
17 | extensions: ['.js', '.vue'],
18 | alias: {
19 | 'vue$': 'vue/dist/vue.esm.js',
20 | '@': path.resolve(__dirname, '../src')
21 | }
22 | },
23 | module: {
24 | rules: [
25 | {
26 | test: /\.vue$/,
27 | loader: 'vue-loader',
28 | options: {
29 | esModule: false
30 | }
31 | },
32 | {
33 | test: /\.js$/,
34 | loader: 'babel-loader',
35 | exclude: /node_modules/
36 | }
37 | ]
38 | }
39 | },
40 | webpackMiddleware: {
41 | noInfo: true
42 | },
43 | coverageReporter: {
44 | dir: './coverage',
45 | reporters: [
46 | { type: 'lcov', subdir: '.' },
47 | { type: 'text-summary' }
48 | ]
49 | },
50 | singleRun: true
51 | })
52 | }
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-birthday-input
2 | vue 生日输入组件
3 |
4 | npm install vue-birthday-input --save
5 |
6 | [](https://www.npmjs.com/package/vue-birthday-input)
7 | [](https://www.npmjs.com/package/vue-birthday-input)
8 | [](https://www.npmjs.com/package/vue-birthday-input)
9 | [](https://travis-ci.org/xanke/vue-birthday-input)
10 | [](https://codecov.io/gh/xanke/vue-birthday-input)
11 | [](http://opensource.org/licenses/MIT)
12 |
13 |
14 | #### 加入模块
15 | ```js
16 | import Vue from 'vue'
17 | import birthdayInput from 'vue-birthday-input'
18 |
19 | export default {
20 | name: 'App',
21 |
22 | components: {
23 | birthdayInput
24 | }
25 | }
26 | ```
27 |
28 | ### 快速开始
29 | ```vue
30 |
31 |
32 |
33 |