(component): 优化 badge 代码警告

This commit is contained in:
就眠儀式 2022-10-18 00:00:04 +08:00
parent 3c808aa9a2
commit 60aaa9fea2
5 changed files with 13 additions and 12 deletions

View File

@ -20,13 +20,13 @@ import {
StyleValue, StyleValue,
} from "vue"; } from "vue";
export interface LayAiffxProps { export interface AiffxProps {
offset?: number; offset?: number;
target?: HTMLElement; target?: HTMLElement;
position?: string; position?: string;
} }
const props = withDefaults(defineProps<LayAiffxProps>(), { const props = withDefaults(defineProps<AiffxProps>(), {
offset: 0, offset: 0,
position: "top", position: "top",
target: () => { target: () => {
@ -134,4 +134,4 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
props.target.removeEventListener("scroll", checkInWindow); props.target.removeEventListener("scroll", checkInWindow);
}); });
</script> </script>

View File

@ -9,7 +9,7 @@ export default {
<script setup lang="ts"> <script setup lang="ts">
import "./index.less"; import "./index.less";
export interface LayAvatarProps { export interface AvatarProps {
src?: string; src?: string;
size?: "xs" | "sm" | "md" | "lg"; size?: "xs" | "sm" | "md" | "lg";
radius?: boolean; radius?: boolean;
@ -17,7 +17,7 @@ export interface LayAvatarProps {
alt?: string; alt?: string;
} }
const props = withDefaults(defineProps<LayAvatarProps>(), { const props = withDefaults(defineProps<AvatarProps>(), {
size: "md", size: "md",
radius: false, radius: false,
icon: "layui-icon-username", icon: "layui-icon-username",

View File

@ -16,7 +16,7 @@ import {
import { LayIcon } from "@layui/icons-vue"; import { LayIcon } from "@layui/icons-vue";
import "./index.less"; import "./index.less";
export interface LayBacktopProps { export interface BackTopProps {
target?: string; target?: string;
showHeight?: number; showHeight?: number;
disabled?: boolean; disabled?: boolean;
@ -34,7 +34,7 @@ export interface LayBacktopProps {
iconColor?: string; iconColor?: string;
} }
const props = withDefaults(defineProps<LayBacktopProps>(), { const props = withDefaults(defineProps<BackTopProps>(), {
target: "window", target: "window",
showHeight: 200, showHeight: 200,
icon: "layui-icon-top", icon: "layui-icon-top",

View File

@ -8,14 +8,14 @@ export default {
import { computed, StyleValue } from "vue"; import { computed, StyleValue } from "vue";
import "./index.less"; import "./index.less";
export interface LayBadgeProps { export interface BadgeProps {
type?: "dot" | "rim"; type?: "dot" | "rim";
theme?: string; theme?: string;
color?: string; color?: string;
ripple?: boolean; ripple?: boolean;
} }
const props = defineProps<LayBadgeProps>(); const props = defineProps<BadgeProps>();
const classes = computed(() => { const classes = computed(() => {
return [ return [
@ -30,8 +30,9 @@ const classes = computed(() => {
}); });
const styles = computed<StyleValue>(() => { const styles = computed<StyleValue>(() => {
props.color ? `background-color: ${props.color}` : ""; return [props.color ? `background-color: ${props.color}` : ""]
}); })
</script> </script>
<template> <template>

View File

@ -61,7 +61,7 @@ const checkedKeys = computed({
return props.multiple ? props.modelValue : []; return props.multiple ? props.modelValue : [];
}, },
set(value) { set(value) {
if(props.multiple) { if (props.multiple) {
emits("update:modelValue", value); emits("update:modelValue", value);
emits("change", value); emits("change", value);
} }