Skip to content

Instantly share code, notes, and snippets.

@fazaio
Created February 21, 2023 19:29
Show Gist options
  • Save fazaio/24c6b80edcb4522662568082a7ff2f11 to your computer and use it in GitHub Desktop.
Save fazaio/24c6b80edcb4522662568082a7ff2f11 to your computer and use it in GitHub Desktop.
vue3 pinia typescript initialize declare variable ref array using interface typescript.
export interface orderCart {
id_product: number;
total_product: number;
}
state: () => {
return {
allProduct: [],
totalAll: "",
checkoutItem: ref<Array<orderCart>>([]),
};
}
addToCart(total_product: number, id_product: number) {
const obj = {
id_product: id_product,
total_product: total_product,
};
this.checkoutItem?.push(obj);
console.log(obj);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment