0.1.0 • Published 5 years ago

ng-code-diff v0.1.0

Weekly downloads
48
License
MIT
Repository
github
Last release
5 years ago

ng-code-diff

此组件是基于vue-code-diff实现的Angular版本代码对比展示工具。

在线演示

安装

npm

npm install ng-code-diff

yarn

yarn add ng-code-diff

使用

app.module.ts

import { NgCodeDiffModule } from 'ng-code-diff';
...
imports: [
  NgCodeDiffModule
]

Typescript

import { Component } from '@angular/core';
import newStr from './data/newStr';
import oldStr from './data/oldStr';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  newStr = newStr;
  oldStr = oldStr;
  context = 5;
  outputFormat = 'side-by-side';
}

HTML

<div>
  <ng-code-diff [newStr]="newStr" [oldStr]="oldStr" [context]="context" [outputFormat]="outputFormat"></ng-code-diff>
</div>

.angular.json - Add styles

"node_modules/diff2html/dist/diff2html.css"

index.html

<script>
    var global = global || window;
    var Buffer = Buffer || [];
    var process = process || {
    env: { DEBUG: undefined },
    version: []
    };
</script>

参数说明

参数说明类型可选值默认值
newStr新的字符串string
oldStr旧的字符串string
context不同地方上下间隔多少行不隐藏number
outputFormat展示的方式stringline-by-line,side-by-sideline-by-line

效果展示

npm.io

LICENSE

MIT

0.1.0

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago