如何在Angular 4中使用CryptoJS [英] How to use CryptoJS with Angular 4

查看:347
本文介绍了如何在Angular 4中使用CryptoJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我不使用Angular 4时,我只是将script标记放入库中.即使将script标记放在index.html文件中,它也无法识别CryptoJS.有没有一种使用库或Angular等效项的方法?

When I was not using Angular 4, I would just put the script tags for the library. Even when I put the script tags in the index.html file it is not recognizing CryptoJS. Is there a way to use the library or a Angular equivalent?

推荐答案

使用NPM安装并在组件文件中导入以下语句.

Install using NPM and import below statement in you component file.

npm install crypto-js

import * as crypto from 'crypto-js';

现在您可以在组件文件中使用加密了.

now you can use crypto in your component file.

这篇关于如何在Angular 4中使用CryptoJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆