Skip to content

Function: effect()

ts
function effect(func: Function, options: EffectOptions): Effect

创建副作用函数

Example

ts
const count = ref(0);
effect(() => {
 console.log(count.value);
})
count.value = 1;
// 打印1

Parameters

ParameterTypeDescription

func

Function

函数

options

EffectOptions

配置

Returns

Effect

effectFunc