【发布时间】:2021-02-27 16:53:38
【问题描述】:
我的一个组件订阅了商店中的一个变量。每当该 store var 发生变化时,我都想触发一个函数。
stores.js
import { writable } from "svelte/store";
export const comparedProducts = writable([1,2,3]);
Component.svelte
import { comparedProducts } from "../stores.js";
//if there is a change in $comparedProducts trigger this function eg. ([1,2])
const someFunction = () => {
//do something
}
【问题讨论】:
标签: svelte svelte-3 svelte-component svelte-store