mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-02 06:06:34 +08:00
perf: simplify watch param
This commit is contained in:
parent
c371301648
commit
e686738fd5
@ -78,7 +78,7 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
computed(() => props.rate),
|
() => props.rate,
|
||||||
(rate) => {
|
(rate) => {
|
||||||
let rafId;
|
let rafId;
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
@ -116,11 +116,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(() => props.time, reset, { immediate: true });
|
||||||
computed(() => props.time),
|
|
||||||
reset,
|
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
if (keepAlived) {
|
if (keepAlived) {
|
||||||
|
@ -59,7 +59,7 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
computed(() => props.src),
|
() => props.src,
|
||||||
() => {
|
() => {
|
||||||
error.value = false;
|
error.value = false;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
@ -21,7 +21,7 @@ export default createComponent({
|
|||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const { parent, index } = useParent(SIDEBAR_KEY, ref());
|
const { parent, index } = useParent(SIDEBAR_KEY, ref());
|
||||||
|
|
||||||
const selected = computed(() => index.value === +parent.active.value);
|
const selected = computed(() => index.value === +parent.active());
|
||||||
|
|
||||||
return (vm) => {
|
return (vm) => {
|
||||||
const { dot, badge, title, disabled } = props;
|
const { dot, badge, title, disabled } = props;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ref, watch, provide, computed } from 'vue';
|
import { ref, watch, provide } from 'vue';
|
||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('sidebar');
|
const [createComponent, bem] = createNamespace('sidebar');
|
||||||
@ -18,7 +18,7 @@ export default createComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const children = ref([]);
|
const children = ref([]);
|
||||||
const index = ref(+props.modelValue);
|
const index = ref(+props.modelValue);
|
||||||
const active = computed(() => props.modelValue);
|
const active = () => props.modelValue;
|
||||||
|
|
||||||
const setIndex = (value) => {
|
const setIndex = (value) => {
|
||||||
if (value !== index.value) {
|
if (value !== index.value) {
|
||||||
@ -27,8 +27,8 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(active, (val) => {
|
watch(active, (value) => {
|
||||||
setIndex(+val);
|
setIndex(+value);
|
||||||
});
|
});
|
||||||
|
|
||||||
provide(SIDEBAR_KEY, {
|
provide(SIDEBAR_KEY, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user