【问题标题】:Module has no exported member 'Md5'?模块没有导出成员'Md5'?
【发布时间】:2019-05-17 16:28:02
【问题描述】:

所以基本上我导入:

import { Md5 } from 'ts-md5/dist/md5';

但它说:

Module has no exported member Md5?

但它工作正常,问题是它在编译时给我一个错误。

我把它改成了小写的 md5,比如:

import { md5 } from 'ts-md5/dist/md5';

但现在我的功能不起作用:

 hashIt(email: string){
    this.hashString = md5.hashStr(email);
    console.log(this.hashString);
  }

上面写着:

Property 'hashStr' does not exist on type '(string : any) => string'.

【问题讨论】:

    标签: angular typescript md5


    【解决方案1】:

    确保已安装npm install --save ts-md5
    将其直接导入您必须使用它的组件中:

    import { Component } from '@angular/core';
    import {Md5} from 'ts-md5/dist/md5';
    
    @Component({
      selector: 'my-app',
      templateUrl: './app.component.html',
      styleUrls: [ './app.component.css' ]
    })
    export class AppComponent  {
      name = 'Angular';
      md5 = new Md5();
      ngOnInit(){
        console.log(this.md5.appendStr('hello').end());
      }
    
    }
    

    工作StackBlitz,如果仍然不工作,试试npm uninstall ts-md5 然后npm install --save ts-md5

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-20
      • 2017-05-07
      • 2017-08-18
      • 2017-09-09
      • 2022-01-12
      • 2021-12-19
      • 2017-03-27
      相关资源
      最近更新 更多