使用带有Typescript和Angular 4的Google代码美化
我对使用Typescript和Angular 4相当陌生,并且我在将Google代码美化与Angular CLI设置集成时遇到了问题 我试图弄清楚如何导入代码prettify以便与我的组件一起动态使用,但我不确定如何实现这一点 我试着用NPM安装并从包中导入PR,但PR作为一个空对象出现使用带有Typescript和Angular 4的Google代码美化,angular,typescript,google-code-prettify,Angular,Typescript,Google Code Prettify,我对使用Typescript和Angular 4相当陌生,并且我在将Google代码美化与Angular CLI设置集成时遇到了问题 我试图弄清楚如何导入代码prettify以便与我的组件一起动态使用,但我不确定如何实现这一点 我试着用NPM安装并从包中导入PR,但PR作为一个空对象出现 有没有办法完成我想做的事情?我还没有机会尝试,但看起来和我想要的一模一样。谢谢 you can change some code in prettify.js: //old code in here if
有没有办法完成我想做的事情?我还没有机会尝试,但看起来和我想要的一模一样。谢谢
you can change some code in prettify.js:
//old code in here
if (typeof define === "function" && define['amd']) {
define("google-code-prettify", [], function () {
return PR;
});
}
//new code in here
if(typeof module==="object"&&typeof module.exports==="object") {
module.exports = PR;
} else if (typeof define === "function" && define['amd']) {
define("google-code-prettify", [], function () {
return PR;
});
}