[英]Partially integrate VueJS with Rails existing app
Current state 当前状态
I have a website fully developed in Rails, using Rails views, classic Coffescript and SCSS. 我有一个使用Rails视图,经典Coffescript和SCSS在Rails中完全开发的网站。 All my routes are declared on routes.rb.
我的所有路线都在route.rb中声明。
What it's needed 需要什么
Some of the pages developed have a lot of logic associated with, and it makes more sense to migrate it to a web app. 开发的某些页面具有很多相关的逻辑,将其迁移到Web应用程序更有意义。 The chosen web app was Vue.js.
选择的Web应用程序是Vue.js。
The whole website (a very complex product) will be incrementally deployed (when the page using Vue.js is ready, the page on the Rails app should be 'replaced' by the new one). 整个网站(一个非常复杂的产品)将被增量部署(当使用Vue.js的页面准备就绪时,应该用新的“替换” Rails应用程序上的页面)。 A major constraint is that the codebase is different .
一个主要的限制是代码库是不同的 。 The Vue.js app will get information from the Rails app API.
Vue.js应用程序将从Rails应用程序API中获取信息。
Problems (help needed) 问题(需要帮助)
How can I set that some routes goes to the Rails app, and others go to the Vue.js app? 如何设置某些路由转到Rails应用程序,而其他路由转到Vue.js应用程序? (remember that are different codebases, different 'physical folders')
(请记住,它们是不同的代码库,不同的“物理文件夹”)
Thanks in advance. 提前致谢。
Have you checked out the webpacker project? 您是否签出了webpacker项目?
If your vue project is already in single vue components, then you can import the component into rails projects. 如果您的vue项目已经在单个vue组件中,则可以将该组件导入Rails项目。
To get started, please follow the readme of webpacker . 要开始使用,请遵循webpacker的自述文件 。
At your rails' view. 在您的视线范围内。
<%= javascript_pack_tag 'components/vue' %>
This way, you can continue to use rails' route. 这样,您可以继续使用Rails的路线。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.