[Vuejs]-Is it possible two-way data-binding withoug an input element in Vue.js?

0👍

Your contract with Vue is that you will work with the viewmodel and Vue will keep it in sync with the DOM.

If Vue doesn’t provide the sort of behavior you need, you tell Vue how to do what you want, by extending it with directives, components, etc.

So in principle, you could have a directive that uses, say, MutationObserver to notice when you’ve replaced a chunk of the DOM, and do something with your viewmodel. Since Vue itself provides better-structured ways of modifying DOM content, it’s almost surely a bad idea. Two-way binding is intended to handle user interaction with the DOM, not programmer modifications of it. The beauty of Vue is that you don’t have to mess with the DOM.

Leave a comment