Answer the question
In order to leave comments, you need to log in
How to re-render in Vue after the template is loaded in a component?
There is this markup:
<script src="/assets/js/vue/vue.js" type="text/javascript"></script>
<script src="/assets/js/vue/vue-router.js" type="text/javascript"></script>
<script src="/assets/js/vue/axios.js" type="text/javascript"></script>
<script src="/assets/js/page/auth.js" type="text/javascript"></script>
<div id="appAuth">
<router-view></router-view>
<div class="bottom-wrapper" v-bind:class="{ hidden: stay=='restore' }">
<router-link to="/restore">восстановить пароль</router-link>.
</div>
<div class="bottom-wrapper" v-bind:class="{ hidden: stay=='auth' }">
<router-link to="/auth">авторизация</router-link>.
</div>
</div>
const auth = {
props: ['name'],
template: '<div v-html="html_block"></div>',
data: function () {
return {
html_block: null
}
},
created () {
// запрашиваем данные когда реактивное представление уже создано
this.fetchData();
},
watch: {
// в случае изменения маршрута запрашиваем данные вновь
'$route': 'fetchData',
},
methods: {
fetchData () {
axios.get('/auth.php?do='+this.name).then( (response) => {
this.html_block = response.data.html;
app.stay = this.name;
});
},
}
};
const routes = [
{ path: '*', component: auth, props: { name: 'auth' } },
{ path: '/auth', component: auth, props: { name: 'auth' } },
{ path: '/restore', component: auth, props: { name: 'restore' } }
];
const router = new VueRouter({
mode: 'history',
routes
});
const app = new Vue({
delimiters: ['<%', '%>'],
data: function () {
return {
stay: "auth"
}
},
methods: {
},
router
}).$mount('#appAuth');
Answer the question
In order to leave comments, you need to log in
Вот тут: https://ru.vuejs.org/v2/api/#v-html
Т.е. ваш вариант не будет работать.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question