Browse Source

信件等级组件响应式缓存bug修复

master
21819 2 years ago
parent
commit
fbecd2e902
  1. 3236
      package-lock.json
  2. 32
      src/components/MailLevel.vue
  3. 1759
      yarn.lock

3236
package-lock.json generated

File diff suppressed because it is too large Load Diff

32
src/components/MailLevel.vue

@ -4,7 +4,10 @@
<span>{{ item.name }}</span>
</div>
</template>
<script setup>
import { ref, watch, computed } from 'vue';
const props = defineProps({
value: {
type: String,
@ -12,29 +15,34 @@ const props = defineProps({
},
list: {
type: Array,
default: [],
default: () => [],
},
});
const item = ref({});
if (props.value && props.list.length) {
item.value = props.list.find((item) => item.value === props.value);
}
const findItem = () => {
return props.list.find((i) => i.value === props.value) || {};
};
watch(
() => props.value,
(val) => {
if (props.value && props.list.length) {
item.value = props.list.find((item) => item.value === props.value);
}
item.value = findItem();
watch(() => props.value, (newVal) => {
item.value = findItem();
});
watch(() => props.list, (newList, oldList) => {
if (!newList.includes(item.value)) {
item.value = findItem();
}
);
}, { deep: true });
</script>
<style lang="scss" scoped>
.dot {
position: relative;
padding-left: 20px;
&::before {
display: block;
content: "";
@ -48,10 +56,12 @@ watch(
top: 50%;
transform: translateY(-50%);
}
&[type="danger"]::before {
background-color: #ff0000;
border-color: #ffbfbf;
}
&[type="warning"]::before {
background-color: #ffa732;
border-color: #ffda2c;

1759
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save