Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. # Rails + webpack + vue
  2. Webpackerのインストール
  3.  
  4.  
  5. $ bin/rails webpack:install
  6.  
  7.  
  8. 以下が作成される
  9.  
  10. - app/javascript/packs/application.js
  11. - bin/webpack
  12. - bin/webpack-dev-server
  13. - bin/webpack-watcher
  14. - config/webpack/development.js
  15. - config/webpack/production.js
  16. - config/webpack/shared.js
  17. - yarn.lock
  18.  
  19. 以下が編集される
  20.  
  21. - .gitignore
  22. - config/environments/development.rb
  23. - config/environments/production.rb
  24. - package.json
  25.  
  26.  
  27. # Vueのインストール
  28. $ rails webpacker:install:vue
  29.  
  30. **app/javascript/packs/app.vue**
  31.  
  32. <template>
  33. <div id="app">
  34. <p>{{ message }}</p>
  35. </div>
  36. </template>
  37.  
  38. <script>
  39. module.exports = {
  40. data: function () {
  41. return {
  42. message: "Hello Vue!"
  43. }
  44. }
  45. }
  46. </script>
  47.  
  48. <style scoped>
  49. p {
  50. font-size: 2em;
  51. text-align: center;
  52. }
  53. </style>
  54.  
  55.  
  56. /* eslint no-console: 0 */
  57. // Run this example by adding <%= javascript_pack_tag 'hello_vue' %>
  58. // to the head of your layout file,
  59. // like app/views/layouts/application.html.erb.
  60. // All it does is render <div>Hello Vue</div> at the bottom of the page.
  61.  
  62. import Vue from 'vue/dist/vue.esm'
  63. import App from './app.vue'
  64.  
  65. document.addEventListener('DOMContentLoaded', () => {
  66. document.body.appendChild(document.createElement('hello'))
  67. const app = new Vue({
  68. el: 'hello',
  69. template: '<App/>',
  70. components: { App }
  71. })
  72.  
  73. console.log(app)
  74. })
  75.  
  76. 以下が編集される
  77.  
  78. - config/webpack/shared.js
  79. - package.json
  80. - yarn.lock
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement