Home > front end >  Try to convert option api to composite api in vue
Try to convert option api to composite api in vue

Time:11-30

all properties I add .value but it still have some thing that not correct
I try to calculate grand total from price multiply by number of purchase that iterate from array

total () {
      return this.items.reduce((total, item) => {
        return total   item.qty * item.price
      }, 0)
    }

I try to change to composite api 118:12 error Parsing error: Missing semicolon. (48:12)

    total () {
      return items.reduce((total, item) => {
        return total   item.qty.value * item.price.value
      }, 0)
    }

CodePudding user response:

try this code

 const total = computed(() => {
      return items.value.reduce((total, item) => {
        return total   item.qty * item.price
      }, 0)
    })
  • Related