- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试进行剑道聊天示例:https://www.telerik.com/kendo-angular-ui/components/conversationalui/
我使用 Visual Studio 代码和 angular 6,我在谷歌搜索但找不到解决方案
但我收到了这个错误:
ERROR in src/app/app.component.ts(68,7): error TS2345: Argument of type 'MonoTypeOperatorFunction' is not assignable to parameter of type 'OperatorFunction'. Types of parameters 'source' and 'source' are incompatible. Type 'Observable' is not assignable to type 'Observable'. Type 'Message' is not assignable to type 'any[]'. Property 'length' is missing in type 'Message'.
import { Component } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { switchMap } from 'rxjs/operators/switchMap';
import { map } from 'rxjs/operators/map';
import { windowCount } from 'rxjs/operators/windowCount';
import { scan } from 'rxjs/operators/scan';
import { take } from 'rxjs/operators/take';
import { tap } from 'rxjs/operators/tap';
import { from } from 'rxjs/observable/from';
import { merge } from 'rxjs/observable/merge';
import { ChatModule, Message, User, Action, ExecuteActionEvent, SendMessageEvent } from '@progress/kendo-angular-conversational-ui';
import { Observable } from 'rxjs/Observable';
import { ChatService } from './chat.service';
@Component({
providers: [ ChatService ],
selector: 'my-app',
template: `
<kendo-chat
[messages]="feed | async"
[user]="user"
(sendMessage)="sendMessage($event)"
>
</kendo-chat>
`
})
export class AppComponent {
public feed: Observable<Message[]>;
public readonly user: User = {
id: 1
};
public readonly bot: User = {
id: 0
};
private local: Subject<Message> = new Subject<Message>();
constructor(private svc: ChatService) {
const hello: Message = {
author: this.bot,
suggestedActions: [{
type: 'reply',
value: 'Neat!'
}, {
type: 'reply',
value: 'Thanks, but this is boring.'
}],
timestamp: new Date(),
text: 'Hello, this is a demo bot. I don\t do much, but I can count symbols!'
};
// Merge local and remote messages into a single stream
this.feed = merge(
from([ hello ]),
this.local,
this.svc.responses.pipe(
map((response): Message => ({
author: this.bot,
text: response
})
))
).pipe(
// ... and emit an array of all messages
scan((acc, x) => [...acc, x], [])
);
}
public sendMessage(e: SendMessageEvent): void {
this.local.next(e.message);
this.local.next({
author: this.bot,
typing: true
});
this.svc.submit(e.message.text);
}
}
scan((acc, x) => [...acc, x], [])
最佳答案
我也遇到了具体问题。尝试以下修复:
scan((acc:any, x) => acc.concat(x), [])
关于angular - 类型 'MonoTypeOperatorFunction<any[]>' 不可分配给类型为“OperatorFunction<Message, any[]>”的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54406225/
我有以下代码: export class EventsChainComponent { eventSubscriber:Subscription; constructor (prote
我试图理解可观察 API 的 pipe 运算符: export declare class Observable implements Subscribable { ....... pipe
我正在尝试进行剑道聊天示例:https://www.telerik.com/kendo-angular-ui/components/conversationalui/ 我使用 Visual Studi
我正在尝试从 rxjs 5 迁移到 6,但我遇到了困难。当我尝试这个时 this._connectivity.isOnline().pipe(first()).subscribe((state) =>
我是一名优秀的程序员,十分优秀!