简体   繁体   English

在VueJs应用程序内部使用Angular6应用程序

[英]Using Angular6 application inside VueJs application

We have Angular application (version 6.1.5), which makes HTTP request to the Restfull API. 我们有Angular应用程序(版本6.1.5),它向Restfull API发出HTTP请求。

We have used modular approach in Angular App. 我们在Angular App中使用了模块化方法。 There is app level routing configurations and each modules have their own routing configuration. 有应用程序级别的路由配置,每个模块都有自己的路由配置。

This set up is perfectly fine and running without any hassles. 此设置非常好,可以轻松运行。

Now as per our new requirement, we need to use this Angular application withing VueJS application. 现在,根据我们的新要求,我们需要将此Angular应用程序与VueJS应用程序一起使用。

After our initial research, we used Angular Elements and created angular build. 经过初步研究,我们使用了Angular Elements并创建了角度构建。 We used this build (containing JS and CSS file) withing the VueJS, we thought it worked fine, until we hit refresh on VueJS application. 我们将此版本(包含JS和CSS文件)与VueJS一起使用,我们认为它运行良好,直到我们在VueJS应用程序上刷新为止。

Once we hit refresh, the Angular application routes are not working and we only see blank screen. 刷新后,Angular应用程序路由将不起作用,我们只会看到空白屏幕。

So what we would like to know is, whether our approach of using angular element is right one. 因此,我们想知道的是,我们使用角度元素的方法是否正确。 Or are there any better approaches to use angular application within VueJS application. 还是有更好的方法在VueJS应用程序中使用角度应用程序。

Thanks for your help. 谢谢你的帮助。

Presumably none of the commenters on the original question are familiar with Web Components (of which Angular Element uses). 大概没有一个原始问题的评论者熟悉Web组件 (Angular Element使用的Web组件 )。 Using multiple frameworks in combination with isolated web components is a perfectly normal and accepted practice . 将多个框架与隔离的Web组件结合使用是一种完全正常且可以接受的做法 In fact, it is likely to become more popular. 实际上,它可能会变得越来越流行。

Anyway, the actual problem here is a fundamental incompatibility of routing libraries. 无论如何,这里的实际问题是路由库的根本不兼容。 Because routing is so tied to the address bar and the HTML 5 History API, child components ( regardless of any framework or web components ) can't simply work how you are expecting it to work. 由于路由与地址栏和HTML 5 History API紧密相连,因此子组件( 无论任何框架或Web组件 )都无法简单地按照您期望的方式工作。 Firstly, Vue Router is in the "parent" component while the Angular ones (via Web Components) try setup routing which then fails. 首先,Vue Router在“父”组件中,而Angular路由器(通过Web组件)尝试设置路由,然后失败。

You will have to refactor your Angular components to not use routing. 您将不得不重构Angular组件以不使用路由。

This isn't a Vue vs Angular vs Web Component problem but a routing problem. 这不是Vue vs Angular vs Web Component问题,而是路由问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM