I have created an app using the Vue CLI webpack and I am facing issues with loading data into a view. Below is the code in its current state:
main.js
// Setting up Vue imports
import Vue from 'vue'
import App from './App'
import router from './router'
// Importing Bootstrap for styling
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Vue.config.productionTip = false
Vue.use(BootstrapVue)
/* Initializing Vue instance */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>',
data: {
exchanges: [
{name: 'gdax', price: 1450},
{name: 'bitfinex', price: 1525}
]
}
})
App.vue
<template>
<div id="app" class="container">
<h1>Arb Bot</h1>
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
margin-top: 60px;
}
</style>
routes/index.js
// Setting up routes
import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Opportunities from '@/components/Opportunities'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '/opportunities',
name: 'Opportunities',
component: Opportunities
}
]
})
Opportunities.vue
<template>
<div>
<h2>Bitcoin prices</h2>
<table>
<tr>
<td>Exchange</td><td>Price</td>
</tr>
<tr v-for="exchange in exchanges" :key="exchange.name">
<td>{{ exchange.name }}</td><td>{{ exchange.price }}</td>
</tr>
</table>
</div>
</template>
The view is rendering properly but the data is not being loaded, hence the table rows are not visible in the browser.
How can I correctly load the data into the view and display the table?
Thank you