S
S
Sergey Sokolov2018-07-31 19:14:58
Vue.js
Sergey Sokolov, 2018-07-31 19:14:58

Why does Vue regenerate el?

I'm trying to render either Backbone View or Vue into the same div. Switch components dynamically. Such are the “difficulties of the transition period” - you have to deal with both technologies in one project for some time.
It turns out that Vue re-creates the element assigned to it:

var el = document.getElementById('app');
// ...
new Vue({el: '#app'});
el === document.getElementById('app') // false

Why is this happening, is it possible to get around this or do I need to create some kind of intermediate element, and Vue should already be attached to it?
Fiddle where either Backbone View or Vue is rendered in one div by buttons. But after the “work” of Vue, you can’t go back to Backbone anymore, because. the div has been recreated and there is no longer a link to it.
Upd. found :
Unlike in Vue 1.x, the mounted element will be replaced with Vue-generated DOM in all cases.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2018-08-01
@sergiks

https://jsfiddle.net/oura9szf/42/
Right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question