首页 > 解决方案 > Angular 5将html导出到图像

问题描述

打扰一下,我如何将 html 导出为角度 5 的图像。

书店什么的?

有没有办法用角度5做到这一点?

标签: angulartypescriptangular5

解决方案


如果你想动态添加图片的 url 链接,这里是代码。您可以将输入文本事件更改为要存储的 HTML 链接。模块 HTML 的 HTML:

<h1>{{title}}</h1>
<div>
        <input type="text" (input)="onInputEvent($event)">
</div>
<div>
    <a [href]='url'>
        <img 
        src="smiley.gif" 
        alt="HTML tutorial" 
        style="width:42px;height:42px;border:0;">
      </a>
</div>

模块打字稿:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'MY TEST';
  url:string ;
  onInputEvent(event:Event){
    this.url=(<HTMLInputElement>event.target).value;
  }
}

推荐阅读