diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..6f40895 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,3 @@ +import Keyboard from './src/components/Keyboard.vue' + +export default Keyboard \ No newline at end of file diff --git a/index.js b/index.js index f1e1060..c8e4dcd 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import Keyboard from '@/components/Keyboard.vue' +import Keyboard from './src/components/Keyboard.vue' Keyboard.install = function(Vue) { Vue.component(Keyboard.name, Keyboard) diff --git a/package.json b/package.json index 4b58a49..c8cfd27 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "main": "index.js", + "types": "index.d.ts", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", @@ -10,7 +11,7 @@ }, "repository": { "type": "git", - "url": "git+http://git.wm-app.xyz/dev/vue-keyborad.git" + "url": "git+https://git.wm-app.xyz/dev/vue-keyborad.git" }, "dependencies": { "core-js": "^3.6.5", diff --git a/src/components/Keyboard.vue b/src/components/Keyboard.vue index 3ee0c63..703a732 100644 --- a/src/components/Keyboard.vue +++ b/src/components/Keyboard.vue @@ -18,13 +18,17 @@ export default { type: String, default: '' }, + width:{ + type: String, + default: 'auto' + }, space: { type: Number, default: 20 }, max: { type: Number, - default: 0 + default: -1 } }, data() { @@ -61,7 +65,11 @@ export default { console.log('==>', this.space) this.$nextTick(() => { let _width = this.$refs.keyboard.clientWidth - this.space * 10; - let normal = _width / 10, special = normal * 1.5 + this.space / 2; + let normal = _width / 10; + if(this.width){ + normal = parseInt(this.width.replace('px','')); + } + const special = normal * 1.5 + this.space / 2; this.normalWidth = normal + 'px' this.specialWidth = special + 'px'; this.totalWidth = _width; @@ -77,7 +85,7 @@ export default { this.originValue = v; } else { // 限制最大长度 - if (this.max > 0 && this.originValue.length < this.max) { + if (this.max < 0 || (this.max > 0 && this.originValue.length < this.max)) { this.originValue.push(key); } } diff --git a/yarn.lock b/yarn.lock index 5e61e0a..37d54f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4984,13 +4984,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -"keybord@git+http://git.wm-app.xyz/dev/vue-keyborad.git": - version "0.1.0" - resolved "git+http://git.wm-app.xyz/dev/vue-keyborad.git#9fdaf7b31ab8ad3a40346b88d672f5789b24707d" - dependencies: - core-js "^3.6.5" - vue "^2.6.11" - killable@^1.0.1: version "1.0.1" resolved "https://registry.npm.taobao.org/killable/download/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"