首页 > 其他分享 >vue computed写法与传参

vue computed写法与传参

时间:2022-10-19 20:00:10浏览次数:59  
标签:传参 vue const computed newName return fullName

// vue2
computed: {
  fullName() {
      return this.firstName + this.lastName;
  }
}
// 传参
computed: {
  fullName() {
    return (params) => {
      
    }
  }
}

// vue3
const newName = computed(() => {
  return name.value + 5     // 注意 ref 包装过的值在value中
})
const newName = computed(() => (item: any) => {
  return item.id==='123'
})

标签:传参,vue,const,computed,newName,return,fullName
From: https://www.cnblogs.com/jia-zq/p/16807556.html

相关文章