From 0718254027c8fc2a1cdb3fa7970890f4f7b8f811 Mon Sep 17 00:00:00 2001 From: qiaopengfei <2646186879@qq.com> Date: Mon, 1 Jul 2024 15:52:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/main.js | 1 + packages/pedestal/src/index.vue | 134 ++++++++++++++++---------------- src/App.vue | 3 +- src/utils/cloneDeep.js | 4 +- 4 files changed, 71 insertions(+), 71 deletions(-) diff --git a/examples/main.js b/examples/main.js index c8a080c..d0e3d09 100644 --- a/examples/main.js +++ b/examples/main.js @@ -3,6 +3,7 @@ import App from '../src/App.vue' //基于element组件封装,引入element组件库 import { Input } from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; Vue.use(Input); // 导入组件库 diff --git a/packages/pedestal/src/index.vue b/packages/pedestal/src/index.vue index bd4b892..c1c9471 100644 --- a/packages/pedestal/src/index.vue +++ b/packages/pedestal/src/index.vue @@ -1,77 +1,75 @@ + + + + + + + + toUpperCase: { + type: Boolean, + default: true, + }, + }, + computed: { + // 所有父级事件 + inputListeners() { + return Object.assign( + {}, + // 我们从父级添加所有的监听器 + this.$listeners, + // 然后我们添加自定义监听器, + // 或覆写一些监听器的行为 + { + // 这里确保组件配合 `v-model` 的工作 + input: (value) => { + this.$emit("input", this.toUpperCase ? value.toUpperCase() : value); + }, + blur: (e) => { + let value = e.target.value + .trim() + .replace(/\s/g, (match) => + match.charCodeAt(0) === 12288 ? String.fromCharCode(32) : match + ); + + // 失去焦点自动首位去空格 + this.$emit("input", value); + }, + } + ); + }, + }, + mounted() {}, +}; + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index e166b4f..7a4c3e7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@