perf: simplify watch param

This commit is contained in:
chenjiahan 2020-08-25 15:12:53 +08:00
parent c371301648
commit e686738fd5
5 changed files with 8 additions and 12 deletions

View File

@ -78,7 +78,7 @@ export default createComponent({
});
watch(
computed(() => props.rate),
() => props.rate,
(rate) => {
let rafId;
const startTime = Date.now();

View File

@ -116,11 +116,7 @@ export default createComponent({
}
};
watch(
computed(() => props.time),
reset,
{ immediate: true }
);
watch(() => props.time, reset, { immediate: true });
onActivated(() => {
if (keepAlived) {

View File

@ -59,7 +59,7 @@ export default createComponent({
});
watch(
computed(() => props.src),
() => props.src,
() => {
error.value = false;
loading.value = true;

View File

@ -21,7 +21,7 @@ export default createComponent({
setup(props, { emit }) {
const { parent, index } = useParent(SIDEBAR_KEY, ref());
const selected = computed(() => index.value === +parent.active.value);
const selected = computed(() => index.value === +parent.active());
return (vm) => {
const { dot, badge, title, disabled } = props;

View File

@ -1,4 +1,4 @@
import { ref, watch, provide, computed } from 'vue';
import { ref, watch, provide } from 'vue';
import { createNamespace } from '../utils';
const [createComponent, bem] = createNamespace('sidebar');
@ -18,7 +18,7 @@ export default createComponent({
setup(props, { emit, slots }) {
const children = ref([]);
const index = ref(+props.modelValue);
const active = computed(() => props.modelValue);
const active = () => props.modelValue;
const setIndex = (value) => {
if (value !== index.value) {
@ -27,8 +27,8 @@ export default createComponent({
}
};
watch(active, (val) => {
setIndex(+val);
watch(active, (value) => {
setIndex(+value);
});
provide(SIDEBAR_KEY, {