简体   繁体   English

将VueJS与Rails现有应用程序部分集成

[英]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.

相关问题 如何在现有的 vuejs 项目中集成 requirejs? - How to integrate requirejs in existing vuejs project? 将 React 组件集成到现有的 NET Core 应用程序中 - Integrate React components into an existing NET Core app 将 Django 与 VueJs 集成 - Integrate Django with VueJs 在 vuejs 应用程序中集成 openlayers - Integrate openlayers in vuejs application 将现有的 vuejs 应用程序转换为使用 nuxt SSR 有多难? - How difficult is to convert an existing vuejs app to use nuxt SSR? 在现有的 Rails 应用程序中嵌入 React 应用程序 - Embedding a React App in an existing Rails App 使用 CDN 将 React 集成到现有的 Node Express 应用程序中 - Integrate React into existing Node express app using CDN 将React Native应用程序集成到现有的iOS Obj-C / Swift应用程序中 - Integrate a React Native app in to an existing iOS Obj-C/Swift App javascript代码部分未在测试环境中执行,可在生产,开发中使用(Rails 3应用) - javascript code partially not executed in test environment, works in production, development (Rails 3 app) 如何使用简单的“a”标签在现有网站中包含使用 npm 和 webpack 构建的 vuejs 应用程序? - how to include a vuejs app build with npm and webpack in an existing website with a simple 'a' tag?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM