简体   繁体   English

Converse.js 渲染到容器中 - 2021

[英]Converse.js render into a container - 2021

First of all, sorry for my English.首先,对不起我的英语。

I want to customize conversejs, so conversejs render its chatbox to another element.我想自定义 conversejs,因此 conversejs 将其聊天框呈现给另一个元素。

I know similar questions were answered by jcbrand, make conversejs.我知道 jcbrand 回答了类似的问题,make conversejs。 Converse.js render into a container Converse.js 渲染到容器中

But the question is too long ago.但这个问题太早了。 And the answer doesn't solve the problem.而答案并不能解决问题。 Because the code has been updated因为代码已经更新了

please re-answer this question请重新回答这个问题

Take a look at https://conversejs.org/trunk/demo/embedded.html for a demo of the chat being inserted into the DOM manually.查看https://conversejs.org/trunk/demo/embedded.html以获取手动插入到 DOM 中的聊天演示。

The code is here: https://github.com/conversejs/converse.js/blob/5dd00659368991b37446208b39e89a65fa8a48fd/demo/embedded.html#L75代码在这里: https : //github.com/conversejs/converse.js/blob/5dd00659368991b37446208b39e89a65fa8a48fd/demo/embedded.html#L75

You can put Converse inside any DOM element by putting a converse-root element inside it.您可以通过将converse-root元素放入任何 DOM 元素中来将 Converse 放入其中。

For example, let's assume you want to put Converse inside a DOM element with id my-element , then you'd do this:例如,假设您想将 Converse 放入 id 为my-element的 DOM my-element ,那么您可以这样做:

<div id="my-element"><converse-root></converse-root></div> . <div id="my-element"><converse-root></converse-root></div>

Unfortunately there is a bug in Converse 8.0.1 that causes this to not work properly.不幸的是,Converse 8.0.1 中存在一个错误,导致它无法正常工作。 It's fixed here: https://github.com/conversejs/converse.js/commit/84c6a0039c78b6e1f1e6054ec9ee42586c45f600它在这里修复: https : //github.com/conversejs/converse.js/commit/84c6a0039c78b6e1f1e6054ec9ee42586c45f600

I will be making a version 9 release soon which contains the fix.我将很快发布包含修复程序的第 9 版。

For now, you can build Converse yourself (just run make dist inside a checkout of the repo, and then you have the necessary files in the ./dist folder).现在,您可以自己构建 Converse(只需在 repo 的检出中运行make dist ,然后在./dist文件夹中就有必要的文件)。

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

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