Using vue v2, I am in the process of developing a Single Page Application (SPA). Within the script section of my vue component, I have defined an Offer class as follows:
class Offer {
constructor(Tariff, TariffCopy, billing, at, fa, backs) {
this.Tariff = Tariff;
this.BaseTariff = TariffCopy;
}
changeSAC(p1, p2) {
...
this.Tariff.provAufwand.SO = this.BaseTariff.provAufwand.SO + Number(p1);
}
}
In this context, Tariff and TariffCopy are instances created from a custom class named Tariff, also specified within the script section of the same component. Essentially, they hold the same values; however, Tariff is subject to modifications, while BaseTariff's values remain static.
class Tariff{
constructor(provAufwand) {
this.provAufwand = provAufwand;
}
}
where
provAufwand= {
SO: 1,
HO5: 2,
HO10: 3,
HO20: 4
}
Upon invoking Offer.changeSAC(p1,p2)
- where p1 and p2 are linked to number inputs via v-model="p1"
and v-model="p2"
, it appears that the value of this.BaseTariff.provAufwand.SO
is unexpectedly modified despite no explicit changes being made to it in the code.
What could be causing this connection between them in my code?