'How to pass data to vue router router-view?
Im using Vue Router. In my code I used to have:
<div v-bind:is="page.component_name" v-bind:page="page"></div>
Which worked, and the page data was passed to the component. But how do I do the same with a router-view? This doesn't seem to work:
<router-view v-bind:page="page"></router-view>
js:
var vm = new Vue({
...,
router : new VueRouter({
routes : [
{ path: '/foo', component: { template: '<div>foo</div>', created:function(){alert(1);} } },
//{ path: '/bar', component: { template: '<div>bar</div>', created:function(){alert(2);} } },
{ path: '/bar', component: Vue.component("ti-page-report") }
]
}),
...
});
Solution 1:[1]
The component ("ti-page-report") that needs to access the props being sent just needs to add it:
<template>
<div>
<h1>Now you can access page: {{ page }}</h1>
</div>
</template>
export default {
name: "TiPageReport",
props: ['page'], // can now be accessed with this.page
...
};
See https://vuejs.org/v2/guide/components-props.html for how to use props properly.
Solution 2:[2]
I personally decided to use provide/inject feature: preserving reactivity with minimal overhead.
Solution 3:[3]
The auto_arima() function automatically returns the best model as an ARIMA model, so you have it saved in you stepwise_model that you also use for training/predicting etc. You can access the parameters via this model:
order = stepwise_model.order
seasonal_order = stepwise_model.seasonal_order
When you create the model with auto_arima(train_data['Sum_QUANTITY'], ...) then you cannot train it with more variables then Sum_QUANTITY. You don't need this line here because the model is already trained by auto_arima():
sm_fit = stepwise_model.fit(train_data)
But if you retrain the model, you must pass the same features to it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Robin Manoli |
| Solution 2 | Mac Slayer |
| Solution 3 |
