vue3的computed计算属性传参

vue3computed计算属性传参


<template>

	<div v-for="item in list">
		<div v-if='isShow(item)'>是否显示</div>
	</div>

	<p> {{ square(num) }} </p>

</template>
 

<script>

	import { ref, computed } from 'vue'
	const currentId = ref(null)
	 
	const isShow = computed(() => (item :any) => {
		return currentId === item.id
	})

	const square = computed(() => (num: number) => {
		return num + num
	})

</script>

你可能感兴趣的:(vue3,vue.js)