I have data of currency
and i wish to pass this data to all views instead of calling same function in each view.
So I've decided to call my function in App.vue (my main view)
but can't figure it how to pass it along with router-view
Code
HTML
<template>
<el-container :is="layout">
<transition name="fade">
<router-view id="content" :key="$route.fullPath"></router-view>
</transition>
</el-container>
</template>
Script
export default {
data() {
return {
isCollapse: true,
user: '',
type: '',
site_name: process.env.MIX_APP_NAME
}
},
created () {
this.currency()
},
methods: {
currency () {
axios
.get('/api/currencyDefault')
.then(response => {
this.currency = response.data.data
})
.catch(function (error) {
console.log('error', error);
});
},
}
}
Any idea?