Feeling a bit frustrated now :( This is my first time trying to use vue.js, which comes after jQuery as the second JS framework I'm diving into on this planet. Here's the HTML code I have:
var main = new Vue({
el: ".main-content",
data: {
heading: "First Vue Page",
usdamount: 0,
currencies: [{
label: "GBP",
rate: 0.7214,
value: 0
},
{
label: "EUR",
rate: 0.80829,
value: 0
},
{
label: "CAD",
rate: 1.2948,
value: 0
}
]
},
computed: {
updateCurrencies: function() {
console.log(this.usdamount);
var usd = parseFloat(this.usdamount);
for (var i = this.currencies.length - 1; i >= 0; i--) {
this.currencies[i].value = this.currencies[i].rate * usd;
}
}
}
});
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<section class="main-content">
<h1>{{ heading }}</h1>
<input type="number" v-on:change="updateCurrencies" v-model="usdamount">
<p class="cur-value" v-for="cur in currencies">
<strong>{{ cur.label }}</strong>: {{ cur.value }}
</p>
</section>
Upon loading the page, everything seems to be working fine and I see a zero logged on the console. However, when I attempt to change the input field, an error message pops up:
TypeError: e is undefined
Stack trace:
we@https://cdn.jsdelivr.net/npm/vue:6:26571
X@https://cdn.jsdelivr.net/npm/vue:6:7441
...
I tried looking into the specific code causing the issue but got even more confused. It seems to be happening within this function:
function we(t,e,n,r){(r||si).removeEventListener(t,e._withTask||e,n)}
Despite multiple attempts at troubleshooting and isolating the problem, I'm still unsure about what's triggering this error.