Angular 4 中的 jsDiff 实现
jsDiff implementation in Angular 4
如何在 Angular 4 中实现 diff-match-patch or jsDiff?
我试过了
import DiffMatchPatch from 'diff-match-patch'
const dmp = new DiffMatchPatch()
const diff = dmp.diff_main('dogs bark', 'cats bark', null, null)
this.foo = diff
并通过
绑定
<div [innerHtml]="foo"></div>
但仍然不知道如何将结果绑定到 my.component.html。上面的示例也不起作用
你可以像这样使用 jsDiff:
import * as jsdiff from 'diff'
...
const diff = jsdiff.diffLines(str1, str2)
如何在 Angular 4 中实现 diff-match-patch or jsDiff?
我试过了
import DiffMatchPatch from 'diff-match-patch'
const dmp = new DiffMatchPatch()
const diff = dmp.diff_main('dogs bark', 'cats bark', null, null)
this.foo = diff
并通过
绑定<div [innerHtml]="foo"></div>
但仍然不知道如何将结果绑定到 my.component.html。上面的示例也不起作用
你可以像这样使用 jsDiff:
import * as jsdiff from 'diff'
...
const diff = jsdiff.diffLines(str1, str2)