This commit is contained in:
qiaopengfei 2024-07-02 15:59:06 +08:00
parent 0718254027
commit e223c14d7e
7 changed files with 121 additions and 19 deletions

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

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

View File

@ -0,0 +1,75 @@
<template>
<el-input
class="ag_input"
:style="{ width }"
:value="value"
:size="size"
v-on="inputListeners"
v-bind="[$attrs]"
>
<slot name="append" slot="append" />
<slot name="prefix" slot="prefix" />
<slot name="suffix" slot="suffix" />
<slot name="prepend" slot="prepend" />
</el-input>
</template>
<script>
/**
* WInput
* @desc 处理输入的输入框(转大写不能有中文空格等)
*/
export default {
name: "AgInput",
props: {
width: {
type: String,
default: "",
},
size: {
type: String,
default: "small",
},
value: {
type: String,
default: "",
},
toUpperCase: {
type: Boolean,
default: false,
},
},
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() {},
};
</script>
<style lang="scss" scoped></style>

View File

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

View File

@ -0,0 +1,18 @@
<template>
<div>
<h1>主组件</h1>
</div>
</template>
<script>
export default {
components: {},
data() {
return {};
},
methods: {},
};
</script>
<style scoped lang='scss'>
</style>

View File

@ -1,6 +1,6 @@
<template>
<el-input
class="w-input"
class="ag_input"
:style="{ width }"
:value="value"
:size="size"
@ -20,11 +20,11 @@
* @desc 处理输入的输入框(转大写不能有中文空格等)
*/
export default {
name: "WInput",
name: "AgInput",
props: {
width: {
type: String,
default: "180px",
default: "",
},
size: {
type: String,
@ -36,7 +36,7 @@ export default {
},
toUpperCase: {
type: Boolean,
default: true,
default: false,
},
},
computed: {

View File

@ -1,6 +1,6 @@
<template>
<div>
<Pedestal ref="ref_Pedestal" v-model="value">
<Pedestal ref="ref_Pedestal" v-model="value" @input="changeInput">
<!-- <template #operate="">
<el-button
class="excel"
@ -42,7 +42,11 @@ export default {
},
};
},
methods: {},
methods: {
changeInput() {
console.log(this.value);
},
},
};
</script>

View File

@ -1,13 +0,0 @@
function cloneDeep(obj, hash = new WeakMap()) {
if (obj == null || typeof obj !== 'object') return obj
if (obj instanceof Date) return new Date(obj)
if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags)
if (hash.has(obj)) return hash.get(obj)
let deepObj = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj))
hash.set(obj, deepObj)
for (const key in obj) {
deepObj[key] = cloneDeep(obj[key], hash)
}
return deepObj
}