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

1759
yarn.lock

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