1👍
✅
You should assign categoryStorage
into a currentCategory
.
Live Demo :
var categoryStorage = 'A'; // You can get the value from local storage here
new Vue({
el: '#app',
data() {
return {
meals: [],
categories: [],
currentCategory: categoryStorage
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<h3 class="meal-title">Recettes de {{ currentCategory }}</h3>
</div>
2👍
Try this:
<h3 class="meal-title">Recettes de {{ currentCategory }}</h3>
export default {
data() {
return {
meals: [],
categories: [],
currentCategory: null,
};
},
// mounted
mounted() {
this.currentCategory = JSON.parse(localStorage.getItem('currentCategory'));
},
};
Source:stackexchange.com