javascript - Botframework-WebChat - 为什么它不能与 Internet Explorer 一起使用?

标签 javascript internet-explorer botframework direct-line-botframework

我的网络聊天在 Chrome 中可以正常工作,但在 IE 中却不能。 我的应用程序是一个 Angular 网站,使用 WebChat 连接到我的机器人。

代码如下所示(从技术上讲,这是 TypeScript,而不是 JavaScript,箭头函数已转译出来):

directLine: DirectLine = new DirectLine({ secret: environment.botDirectLineSecretKey }) 

@ViewChild("botWindow") botWindowElement: ElementRef;

ngOnInit() {

    this.directLine.activity$
      .filter(activity => activity.type === "event" && activity.name === "init")
      .subscribe(activity => this.changeSize());

    BotChat.App({
      botConnection: this.directLine,
      user: { id: 'user' },
      bot: { id: 'bot' },
    }, this.botWindowElement.nativeElement);

}

changeSize(){
    console.log("here")
    var container = document.getElementById("bot-chat-container");
    container.classList.add("fullSize");
}  

在 Internet Explorer 中,我在控制台中收到此错误:

ERROR TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

如果我将 botConnection: this.directLine 切换为 directLine: this.directLine,网络聊天可以工作,但永远不会调用 changeSize() 方法。

感谢任何帮助。该机器人正在公共(public)网站上运行,并且必须支持 IE。

最佳答案

我找到了答案。在阅读了发布的答案和评论后,我创建了此代码的“普通”html/JavaScript 版本,正如上面 Eric Dahlvang 所说,它运行得很好。然后我暂时专注于 Angular 方面。

然后我注意到我的原始 Angular 代码与我的纯 JavaScript 版本以及此处找到的示例之间存在一个差异:https://github.com/Microsoft/BotFramework-WebChat 。我做了一个简单的改变:

改变了这一点: directLine: DirectLine = new DirectLine({secret:environment.botDirectLineSecretKey })

对此: directLine: DirectLine = new BotChat.DirectLine({secret:environment.botDirectLineSecretKey })(请注意,我现在使用BotChat.DirectLine)

一切正常。不幸的是,我不知道为什么。

关于javascript - Botframework-WebChat - 为什么它不能与 Internet Explorer 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48304605/

相关文章:

javascript - 另一个 .js 文件中的异步函数在返回时卡住

javascript - 我可以更改循环中使用的 ID 吗?需要在 6 次迭代中更改 1 个字符

c# - Microsoft Bot Framework - Facebook 集成 - Net Framework

c# - 空 botId - Microsoft Bot Framework SDK V3

python - 使用python将自适应卡添加到bot框架

javascript - 使用 javascript 从 HTML 转换 Word 文档时添加图像时遇到问题

javascript - 如何使用上一个/下一个按钮循环浏览图像?

css - 为什么这个 html/css 在 ie 中不起作用?

javascript - SVG 在 IE 上无法正确渲染

javascript - :hover CSS style affecting browser-based behaviour of buttons containing image