Skip to content

Commit 8796920

Browse files
committed
2 parents ac7257e + 500e640 commit 8796920

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# VueOnRails
22

3-
Easy and simple way to use Vue.js with Ruby on Rails and Turbolinks 5.
3+
Simple and fast way to use Vue.js with Ruby on Rails and Turbolinks 5.
44

5-
This gem is intended to sprinkle your Rails app with Vue components. Really lightweight script (1.3KB minified) that mount and destroy Vue components on demand. It's works nicely with Turbolinks rendering and caching system.
5+
This gem is fantastic to sprinkle your web page with Vue components. Lightweight script (1KB minified) that mounts and destroys Vue components on demand.
6+
7+
It works nicely with:
8+
- Turbolinks rendering and caching system
9+
- Javascript loaded asynchronously with defer or async script attribute
10+
11+
It's fully Google PageSpeed friendly since you can use it with defer or async, no need for render-blocking JavaScript :)
612

713
If you are building a pure SPA app with Vue and Rails without Turbolinks, you will be better off looking into:
814
https://github.com/adambutler/vuejs-rails
@@ -39,19 +45,23 @@ Require vue_on_rails in application.js
3945
Mount and destroy Vue components:
4046
```
4147
# Mount Vue components
42-
document.addEventListener 'turbolinks:load', ->
43-
VueOnRails.mountComponents()
48+
document.addEventListener('turbolinks:load', function() {
49+
VueOnRails.mountComponents();
50+
});
4451
4552
# Destroy Vue components
46-
document.addEventListener 'turbolinks:before-render', ->
47-
VueOnRails.destroyComponents()
53+
document.addEventListener('turbolinks:before-render', function() {
54+
VueOnRails.destroyComponents();
55+
});
4856
```
57+
VueOnRails.mountComponents() will scan the page and mount components using data-vue-component and data-vue-props.
4958

50-
Example Vue component in my_component.coffee
59+
Example Vue component in my_component.js
5160
```
52-
@MyComponent =
53-
props: ['myProp']
61+
MyComponent = {
62+
props: ['myProp'],
5463
template: '<div>A custom component with {{myProp}}</div>'
64+
};
5565
```
5666

5767
Add component in view.html.erb
@@ -85,7 +95,7 @@ Props are automatically hyphen-delimited to follow vuejs and HTML5 standard.
8595

8696
### Dynamic props
8797
```
88-
<%= vue_component 'MessageComponent', ':my_message': 'hello world' %>
98+
<%= vue_component 'MessageComponent', ':my_object': { title: 'Test', subtitle: 'Sweet!' } %>
8999
```
90100

91101
## Contributing

0 commit comments

Comments
 (0)