Can Vue be used to create a binding where the data item in the Vue instance is initialized from the DOM?
In my specific case, I want my Vue instance to receive the action
attribute of a form element.
For example, this is how my HTML would look like (the path is generated using server-side code):
<form action="path/to/script.php" id="my-form">
</form>
This is how my Vue element would be defined:
new Vue({
el: 'my-form',
data: {
action: '' // I want this item to receive 'path/to/script.php' on load
},
compiled: function() {
console.log(this.action); // Should output 'path/to/script.php'
}
});
I have attempted to achieve this without success. The action in the DOM gets removed to match the action
data item:
<form action="path/to/script.php" v-bind:action="action">
</form>
Thank you