为什么一个空白的html返回

时间:2017-11-19 13:45:13

标签: javascript html

我从这个site获得了这个模板:在尝试了一些模板后,它们没问题。但尝试这个僵尸模板我得到一个空白的html返回此代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>BotUI - Hello World</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="https://unpkg.com/botui/build/botui.min.css" />
    <link rel="stylesheet" href="https://unpkg.com/botui/build/botui-theme-default.css" />
    <meta name="description" content="A hello world bot. A conversational UI built using BotUI.">
  </head>
  <body>
    <div class="botui-app-container" id="hello-world">
      <bot-ui></bot-ui>
    </div>
    <script src="https://cdn.jsdelivr.net/vue/latest/vue.min.js"></script>
    <script src="https://unpkg.com/botui/build/botui.js"></script>
    <script>
    var botui = new BotUI('hello-world');

    botui.message.add({
      content: 'Hello World from bot!'
    });

    botui.message.add({
      human: true,
      content: 'Hello World from human!'
    });

    document.getElementById("hello-world").innerHTML = content;
    </script>

  </body>
</html>

可能是什么问题? 此致

1 个答案:

答案 0 :(得分:3)

模板工作正常,这里唯一的问题是您需要删除以下行

document.getElementById("hello-world").innerHTML = content;

我不确定,为什么你添加了这一行。所有消息都应通过botui.message.add()方法呈现。 BotUI将处理内容插入。

&#13;
&#13;
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>BotUI - Hello World</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="https://unpkg.com/botui/build/botui.min.css" />
    <link rel="stylesheet" href="https://unpkg.com/botui/build/botui-theme-default.css" />
    <meta name="description" content="A hello world bot. A conversational UI built using BotUI.">
  </head>
  <body>
    <div class="botui-app-container" id="hello-world">
      <bot-ui></bot-ui>
    </div>
    <script src="https://cdn.jsdelivr.net/vue/latest/vue.min.js"></script>
    <script src="https://unpkg.com/botui/build/botui.js"></script>
    <script>
    var botui = new BotUI('hello-world');

    botui.message.add({
      content: 'Hello World from bot!'
    });

    botui.message.add({
      human: true,
      content: 'Hello World from human!'
    });

    // document.getElementById("hello-world").innerHTML = content;
    </script>

  </body>
</html>
&#13;
&#13;
&#13;