Skip to content

Function: computed()

ts
function computed<T>(getter: () => {
  value: T;
 }): {
  get value: any;
}

获取计算属性

Example

ts
const count = ref(0);
const double = computed(() => count.value * 2);
console.log(double.value); //0
count.value = 1;
console.log(double.value); //2

Type Parameters

Type Parameter

T

Parameters

ParameterTypeDescription

getter

() => { value: T; }

Returns

ts
{
  get value: any;
}

computed

NameType
get valueany