【发布时间】:2020-12-13 18:29:18
【问题描述】:
我想在 Angular 应用程序中使用 google diff/match/patch lib 来显示两个文本之间的差异。
我的用法是这样的:
public ContentHtml: SafeHtml;
compare(text1: string, text2: string):void {
var dmp = new diff_match_patch();
dmp.Diff_Timeout = 1;
dmp.Diff_EditCost = 4;
var d = dmp.diff_main(text1, text2);
dmp.diff_cleanupSemantic(d);
var ds = dmp.diff_prettyHtml(d);
this.ContentHtml = this._sanitizer.bypassSecurityTrustHtml(ds);
}
问题是,如何为这条线导入diff_match_patch?var dmp = new diff_match_patch();
【问题讨论】:
标签: javascript angular typescript google-diff-match-patch