feat: add input allow-clear props
This commit is contained in:
parent
794dbb77fd
commit
3e22cfb2fe
@ -83,6 +83,32 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: title 允许清空
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: demo
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<lay-input allow-clear="true" v-model="value1"></lay-input>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
|
||||||
|
const value1 = ref("内容")
|
||||||
|
|
||||||
|
return {
|
||||||
|
value1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
::: title 事件回调
|
::: title 事件回调
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>[新增] input 组件 prefix 插槽, 提供前缀设置。</li>
|
<li>[新增] input 组件 prefix 插槽, 提供前缀设置。</li>
|
||||||
<li>[新增] input 组件 suffix 插槽, 提供后缀设置。</li>
|
<li>[新增] input 组件 suffix 插槽, 提供后缀设置。</li>
|
||||||
|
<li>[新增] input 组件 allow-clear 属性, 提供输入清空。</li>
|
||||||
<li>[新增] transition 组件 type 属性, 默认为 collapse 过渡。</li>
|
<li>[新增] transition 组件 type 属性, 默认为 collapse 过渡。</li>
|
||||||
<li>[新增] transition 组件 type 属性 fade 值, 提供淡出淡入效果。</li>
|
<li>[新增] transition 组件 type 属性 fade 值, 提供淡出淡入效果。</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex: none;
|
flex: none;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-input-suffix {
|
.layui-input-suffix {
|
||||||
@ -40,6 +41,13 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layui-input-clear {
|
||||||
|
display: flex;
|
||||||
|
flex: none;
|
||||||
|
align-items: center;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.layui-input:hover {
|
.layui-input:hover {
|
||||||
border-color: #eee !important;
|
border-color: #eee !important;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export default {
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import "./index.less";
|
import "./index.less";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useSlots } from "vue-demi";
|
import { computed, useSlots } from "vue-demi";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
@ -17,8 +17,9 @@ export interface LayInputProps {
|
|||||||
type?: string;
|
type?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
modelValue?: string | number;
|
modelValue?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
allowClear?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<LayInputProps>(), {});
|
const props = withDefaults(defineProps<LayInputProps>(), {});
|
||||||
@ -38,6 +39,10 @@ const onFocus = function (event: FocusEvent) {
|
|||||||
const onBlur = function () {
|
const onBlur = function () {
|
||||||
emit("blur");
|
emit("blur");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clear = () => {
|
||||||
|
emit("update:modelValue", "");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -60,5 +65,8 @@ const onBlur = function () {
|
|||||||
<span class="layui-input-suffix" v-if="slots.suffix">
|
<span class="layui-input-suffix" v-if="slots.suffix">
|
||||||
<slot name="suffix"></slot>
|
<slot name="suffix"></slot>
|
||||||
</span>
|
</span>
|
||||||
|
<span class="layui-input-clear" v-if="allowClear">
|
||||||
|
<lay-icon type="layui-icon-close-fill" @click="clear"></lay-icon>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<LayCollapseTransition v-if="type === 'collapse'"
|
<LayCollapseTransition v-if="type === 'collapse'"><slot></slot></LayCollapseTransition>
|
||||||
><slot></slot
|
|
||||||
></LayCollapseTransition>
|
|
||||||
<LayFadeTransition v-if="type === 'fade'"><slot></slot></LayFadeTransition>
|
<LayFadeTransition v-if="type === 'fade'"><slot></slot></LayFadeTransition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -128,14 +128,12 @@ class Tree {
|
|||||||
if (!originMap.has(nodeKey)) {
|
if (!originMap.has(nodeKey)) {
|
||||||
originMap.set(nodeKey, origin);
|
originMap.set(nodeKey, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
|
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
|
||||||
const len = nodes.length;
|
const len = nodes.length;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
//console.log(nodes[i], checked);
|
|
||||||
nodes[i].isChecked.value = checked;
|
nodes[i].isChecked.value = checked;
|
||||||
nodes[i].children &&
|
nodes[i].children &&
|
||||||
nodes[i].children.length > 0 &&
|
nodes[i].children.length > 0 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user