I want to use an external JS function into a vue file.
Js file contains the method:
let calculateDiscount = {
PriceAfterDiscount(price, discountPercentage) {
const discountAmount = (discountPercentage * price) / 100;
return price - discountAmount;
}
};
export default calculateDiscount;
Vue file
<template>
<div v-for="product in product_data" :key="product.id">
<h4> ${{ Discount(product.price, product.sale) }}</h4>
</div>
</template>
<script>
import CalculateDiscount from "@/utilities/CalculateDiscount"; //js file containing the method
name: "ShowProduct",
methods: {
Discount(){
CalculateDiscount.PriceAfterDiscount();
}
}
</script>
I far I guess I can't import the function in method property in the right manner. Can anyone help me? Thanks in advance.