angluar 使用markdown编辑器vditor
- npm 安装
npm install vditor --save --force
- angular.json引入样式文件node_modules/vditor/src/assets/less/index.less
"styles": ["node_modules/vditor/src/assets/less/index.less",]
component.ts中导入vditor
import { Component, OnInit } from '@angular/core';import {ActivatedRoute} from '@angular/router';import Vditor from 'vditor';@Component({selector: 'app-article-detail',templateUrl: './article-detail.component.html',styleUrls: ['./article-detail.component.less'],})export class ArticleDetailComponent implements OnInit {vditor: Vditor;constructor(private activatedRoute: ActivatedRoute) { }ngOnInit() {this.vditor = new Vditor('vditor', {height: 360,//"dark" | "light"mode: "wysiwyg",theme: "dark",toolbarConfig: {pin: true,},cache: {enable: false,},after: () => {this.vditor.setValue('Hello, Vditor + Angular!');}});}}
- html中
<div id="vditor"></div>
- 完成