JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.4.0/vue-router.js"></script>
<div id="app">
<router-view></router-view>
<router-link to="/">Home</router-link>
<router-link to="/arizona">Arizona</router-link>
</div>
JavaScript
console.clear()
Vue.use(VueRouter)
const Map = {
data() {
return {
loading: true,
load: ''
}
},
template:`
<div>
dataFile: {{dataFile}} <br>
mapFile: {{mapFile}} <br>
mapType: {{mapType}}
</div>
`,
props: ['dataFile', 'mapFile', 'mapType'],
methods:{
drawMap(){
console.log("do a bunch a d3 stuff")
}
},
updated(){
console.log('updated')
this.drawMap()
},
mounted() {
console.log('mounted')
this.drawMap()
}
}
const routes = [
{
name: 'MainMap',
path: '/',
props: {
dataFile: 'all_resv.csv',
mapFile: 'contig_us.geo.json',
mapType: 'us'
},
folder: true,
component: Map
},
{
name: 'Arizona',
path: '/arizona',
props: {
dataFile: 'az.csv',
mapFile: 'az.counties.json',
mapType: 'state'
},
folder: true,
component: Map
}
]
const router = new VueRouter({
routes
})
new Vue({
el: "#app",
router
})