嵌入模式:在vue3动态创建script标签embed.min.js引入之后,没有创建机器人,引入失败? #76

Closed
opened 2026-02-16 05:19:07 -05:00 by yindo · 1 comment
Owner

Originally created by @AfterTheStars on GitHub (Jun 2, 2025).

问题描述

嵌入模式:在vue3动态创建script标签embed.min.js引入之后,没有创建机器人,引入失败?

页面链接

<script setup lang="ts"> import { onBeforeMount } from 'vue' onBeforeMount(() => { const configScript = document.createElement('script') configScript.textContent = ` window.difyChatbotConfig = { token: 'NQqg8G3xzTQLrKNV', baseUrl: 'http://172.28.138.205', systemVariables: { user_id: '123' } } ` document.head.appendChild(configScript) // window.difyChatbotConfig = { // token: 'NQqg8G3xzTQLrKNV', // baseUrl: 'http://172.28.138.205', // systemVariables: { // user_id: '123' // } // } const embedScript = document.createElement('script') embedScript.src = 'http://172.28.138.205/embed.min.js' embedScript.id = 'NQqg8G3xzTQLrKNV' // embedScript.defer = true embedScript.onload = function () { console.log(window.difyChatbotConfig) } document.head.appendChild(embedScript) }) </script>

建议修改

Originally created by @AfterTheStars on GitHub (Jun 2, 2025). ## 问题描述 嵌入模式:在vue3动态创建script标签embed.min.js引入之后,没有创建机器人,引入失败? ## 页面链接 <template> <div class="chatbot-container"></div> </template> <script setup lang="ts"> import { onBeforeMount } from 'vue' onBeforeMount(() => { const configScript = document.createElement('script') configScript.textContent = ` window.difyChatbotConfig = { token: 'NQqg8G3xzTQLrKNV', baseUrl: 'http://172.28.138.205', systemVariables: { user_id: '123' } } ` document.head.appendChild(configScript) // window.difyChatbotConfig = { // token: 'NQqg8G3xzTQLrKNV', // baseUrl: 'http://172.28.138.205', // systemVariables: { // user_id: '123' // } // } const embedScript = document.createElement('script') embedScript.src = 'http://172.28.138.205/embed.min.js' embedScript.id = 'NQqg8G3xzTQLrKNV' // embedScript.defer = true embedScript.onload = function () { console.log(window.difyChatbotConfig) } document.head.appendChild(embedScript) }) </script> ## 建议修改
yindo closed this issue 2026-02-16 05:19:07 -05:00
Author
Owner

@AllenWriter commented on GitHub (Jun 3, 2025):

Hi, this is the documentation repo, not a technical support channel.
I’m afraid unable to address the issue you mentioned here.

@AllenWriter commented on GitHub (Jun 3, 2025): Hi, this is the documentation repo, not a technical support channel. I’m afraid unable to address the issue you mentioned here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-docs#76