I am in the process of adding Vue.js to my Rails 6 app. The project is using turbolinks so "vue-turbolinks" is installed via yarn and my Vue config looks like this:
import TurbolinksAdapter from 'vue-turbolinks';
import Vue from 'vue/dist/vue.esm';
Vue.use(TurbolinksAdapter);
document.addEventListener('turbolinks:load', () => {
const app = new Vue({
el: '[data-behavior="vue"]',
data() {
return {
message: 'This string will update with input from text field',
};
},
methods: {
updateMessage(event) {
this.message = event.target.value;
},
}
});
});
and my rails template(.html.erb) contains a text field with a Vuejs "v-model" attribute
<div data-behavior="vue">
{{ message }}
<%= f.text_field :title, "v-model": "updateMessage" %>
</div>
Vue seems to be working as expected, except "v-model" is outputting literal function instead of calling the function(updateMessage). As a result the text field renders with value of
"function () { [native code] }"
However changing "v-model" to "v-on:input" does what i expect it to do: update the message on input.
Can anyone shed light on whats happening here or point me in the right direction for troubleshooting this. Thanks for your time in advance.