Open jtwang7 opened 2 years ago
参考文章:vue computed传参
✅ 计算属性不能直接传参 ✅ 计算属性传参需要返回一个函数实现 (而不是单单返回一个值),通过调用返回的函数,传入具体参数来计算返回数据
export default { data () { return {} }, computed: { test() { return function(index){ return this.data[index].num } } } }
// computed() 里的写法 const isIconActive = computed(() => (id: number) => (id === currentIconId.value))
Vue computed 传参
参考文章:vue computed传参
✅ 计算属性不能直接传参 ✅ 计算属性传参需要返回一个函数实现 (而不是单单返回一个值),通过调用返回的函数,传入具体参数来计算返回数据