Ask A Question

Notifications

You’re not receiving notifications from this thread.

Vue.js Components in Rails Views Discussion

Guys, I feel very stupid asking this but I still don't understand what is the purpose of data-behavior="vue" to initialize the Vue instance. How does this differ compared to doing <div id="app"><%= yield %></div> ? It feels like the serve exactly the same purpose.

Reply

This looks like Rails UJS born-again: add in a simple html attribute and BOOM: you get all this functionality for free with minimal effort. I would also add that if this approach is combined with a stimulus controller: and you can load and initialize vue components via AJAX, or turbo_frames, or even turbo streams. best bit.

Reply

are there any differences using it with turbo js now?

Reply

Could you post how to migrate for Rails 7 + Esbuild?
I tried but I got
Failed to mount app: mount target selector "app" returned null.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.