简体   繁体   English

Vue - 我如何在 window 中加载组件?

[英]Vue - how can i load a component in a window?

I'm trying to use Winbox JS to add windows to my Vue project.我正在尝试使用 Winbox JS将 windows 添加到我的 Vue 项目中。 Inside of those windows, i would like to render dynamic components.在那些 windows 里面,我想渲染动态组件。 The problem with my code is that while i can create the windows, i can't find a way to load the components as well.我的代码的问题是,虽然我可以创建 windows,但我也找不到加载组件的方法。

Here is what i tried:这是我尝试过的:

App.vue应用程序.vue

<template>
  <div id="app">
    <button-counter />
    <button @click="spwanbox()" variant="primary">Create winbox</button>
  </div>
</template>

<script>
export default {
  name: "App",
  mounted() {},
  methods: {
    spwanbox() {
      new WinBox("testing", {
        heigth: 100,
        width: 300,
        x: 10,
        y: 50,
        html: "<button-counter />",
      });
    },
  },
};
</script>

Here the button will successfully create the window, but the component is not loaded inside the window.此处按钮将成功创建 window,但组件未加载到 window 内。 What am i doing wrong?我究竟做错了什么? Any kind of advice is appreciated.任何形式的建议表示赞赏。

Here is a full code sandbox repository: https://codesandbox.io/s/great-mclean-7lbsq?file=/src/App.vue:0-404这是一个完整的代码沙盒存储库: https://codesandbox.io/s/great-mclean-7lbsq?file=/src/App.vue:0-404

The WinBox.js package does not seem to have any support for integrating with Vue. WinBox.js package 似乎不支持与 Vue 集成。 The content inside one of its windows is not part of your Vue app and can't use props, data, methods, components, etc. Options include:其中一个 windows 里面的内容不是你的 Vue 应用程序的一部分,不能使用道具、数据、方法、组件等。选项包括:

  • mounting a secondary Vue app into the WinBox window and bridging data between the apps as needed (fully functional, but possibly tedious to code)将辅助 Vue 应用程序安装到 WinBox window 并根据需要在应用程序之间桥接数据(功能齐全,但编码可能很乏味)
  • using the WinBox mount option (see example on its home page) to clone content from your app into one of its windows (loses all reactivity and interactivity, so not much of an option)使用 WinBox mount选项(参见其主页上的示例)将应用程序中的内容克隆到其 windows 之一(失去所有反应性和交互性,因此没有太多选择)
  • migrating to Vue 3 and using its teleport feature to place content from your app into WinBox windows (cleanest, but the migration may present difficulties)迁移到 Vue 3 并使用其传送功能将内容从您的应用程序放入 WinBox windows(最干净,但迁移可能会遇到困难)

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

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