I'm learning Vue and I'm doing a simple calculator app, but I cannot seem to get it to work without errors. I currently just print the numbers and the operator to test but I get the "Vue is not defined error" in the console every time. I have other "apps" currently on the same page, e.g. rolling a dice which generates no errors; when I remove the calculator tab the console errors disappear.
I have also tried removing the Vue definition from the data()-function as well as some other things. The console log also complains that my variables number1, number2, and operations is not defined in the instance but referenced during render. Currently you can choose a numbers and the operator and the program will print them anyway.
<template>
<div id="calc">
<h2>Calculator</h2>
<input v-model.number="number1" placeholder="Write a number">
<select v-model="operations" id="ope">
<option disabled value="">Select one</option>
<option id='plus'>+</option>
<option id='minus'>-</option>
<option id='multiply'>*</option>
<option id='divide'>/</option>
</select>
<input v-model.number="number2" placeholder="Write a number">
<p>{{ number1 }} {{ operations }} {{ number2 }}</p>
</div>
</template>
<style>
input {
text-align: center;
width: 100px;
margin: 7px;
}
</style>
<script>
export default {
data() {
var vm = new Vue({
el: '#ope',
data:{
operations: '',
number1: '',
number2: '',
},
methods:{
plus(){
},
minus(){
},
multiply(){
},
divide(){
},
}
})
}
}
</script>
My main mounts the App.vue file which consists of
<template>
<div id="app">
<header><p>Yup this is a header</p></header>
<div id="nav">
<router-link to="/">Start</router-link>
<router-link to="/dice">Dice</router-link>
<router-link to="/faq">FAQ</router-link>
<router-link to="/calculator">Calculator</router-link>
</div>
<div id="content">
<router-view/>
</div>
<footer>
<p>Yes this is a footer</p>
</footer>
</div>
</template>