【问题标题】:Using Google Code-Prettify with Typescript and Angular 4使用带有 Typescript 和 Angular 4 的 Google Code-Prettify
【发布时间】:2017-04-15 00:46:07
【问题描述】:

我对使用 Typescript 和 Angular 4 还很陌生,我在将 Google Code-Prettify 与 Angular CLI 设置集成时遇到了麻烦。

我正试图弄清楚如何导入代码美化以动态地与我的组件一起使用,但我不确定如何实现这一点。

我尝试使用 NPM 安装并从包中导入 PR,但 PR 以空对象的形式出现。

有没有办法完成我想做的事情?

【问题讨论】:

    标签: angular typescript google-code-prettify


    【解决方案1】:
    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;
        });
    }
    use case like this:
    let prettify = require('../../dep/prettify');
    $("#doc-view").html(virtualDom);
    prettify.prettyPrint();

    【讨论】:

    • 我还没有机会尝试这个,但看起来和我要找的完全一样。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 2012-12-06
    相关资源
    最近更新 更多