diff --git a/README.md b/README.md index afd2d75ac..06f529de4 100644 --- a/README.md +++ b/README.md @@ -604,6 +604,8 @@ document.addEventListener('DOMContentLoaded', () => { #### Vue +Add the data as attributes in the element you are going to use (or any other element for that matter). + ```erb <%= content_tag :div, id: "hello-vue", @@ -614,17 +616,50 @@ document.addEventListener('DOMContentLoaded', () => { <% end %> ``` +This should produce the following HTML: + ```html -
+
+``` + +Now, modify your Vue app to expect the properties. + +```html + + + + + + ``` + ```js -// Render component with props document.addEventListener('DOMContentLoaded', () => { + + // Get the properties BEFORE the app is instantiated const node = document.getElementById('hello-vue') const props = JSON.parse(node.getAttribute('data')) + // Render component with props new Vue({ render: h => h(App, { props }) }).$mount('#hello-vue');