如何在另一个 vue 应用程序中包含 vue 应用程序? [英] How to include vue app inside another vue app?
问题描述
我目前被要求生成将包含在不同客户网站中的小部件.
I'm currently requested to generate widget that will be included in different customers web sites.
让我们这样说:
有两个限制:
- 禁止使用 iframe
- 客户网站可以使用任何语言(PHP、React、Angular、Vue.js、JQuery 等)来完成
由于请求的小部件应该是交互式的,我想使用 javascript 框架来开发它(我想到了 Vue.js).
As the requested widget should be interactive, I wanted to develop it using javascript framwork (I thought about Vue.js).
但是,我认为这可能会导致一些冲突(甚至破坏客户的网站),例如,如果客户的网站已经在使用其他版本的 Vue.js.
However, I thought that this could lead to some conflicts (or even break customer's website) for instance if the customer's website is already use another version of Vue.js.
我花了几个小时寻找和思考一个解决方案,但希望使用 iframe 我没有找到任何东西......
I spent several hours looking and thinking about a solution, but expect using an iframe I didn't found anything...
=> 有没有办法将 Vue.js 应用程序包含在另一个 Vue.js 应用程序(或 React、Angular 等)中?
=> Is there a way to include Vue.js apps inside another Vue.js app (or React, Angular, ...) ?
预先感谢您的帮助.
推荐答案
我怀疑您最有可能遇到的问题是版本是否不同(客户端使用 Vue 2.5,而您使用 2.6).
The problem, I suspect, you'll most likely run into is if the versions differ (client uses Vue 2.5, you use 2.6).
我过去曾在 React 和 Vue 中遇到过这种情况.
I've ran into this with React and Vue in the past.
这可能是我非常喜欢在我了解项目的情况下使用 Svelte 的第一大原因将用作依赖项/小部件.
This is probably the #1 reason I'm so big on using Svelte in instances where I know the project will be used as a dependency/widget.
如果你习惯了 Vue,你应该很快就会有家的感觉.显着的区别在于它在技术上是一种语言,而不是框架,从 dist 包中编译框架,因此您没有框架依赖.
If you're used to Vue, you should feel home pretty quick. The notable difference is that it is technically a language, not a framework, that compiles the framework out of the dist bundle, so you don't have the framework dependency.
这篇关于如何在另一个 vue 应用程序中包含 vue 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!