當前我正在使用require.js來開發一個有趣的項目我工作的一切工作都很好,除了代碼語法higlighting plugin prism.js。我可以看到插件是通過chrome中的網絡選項卡拉取的,但插件未初始化。使用require.js加載非amd模塊
我不確定這是否是一個需要解決的問題,或者如果插件是問題,並想知道是否有人可以提供幫助。
下面來看看我main.js:
require.config({
// 3rd party script alias names
paths: {
// Core Libraries
modernizr: "libs/modernizr",
jquery: "libs/jquery",
underscore: "libs/lodash",
backbone: "libs/backbone",
handlebars: "libs/handlebars",
text: "libs/text",
prism: "plugins/prism",
templates: "../templates"
},
// Sets the configuration for your third party scripts that are not AMD compatible
shim: {
"backbone": {
"deps": ["underscore", "jquery", "handlebars"],
"exports": "Backbone" //attaches "Backbone" to the window object
}
}
});
// Include Specific JavaScript
require(['prism', 'modernizr', 'jquery', 'backbone', 'routers/router', 'views/AppVIew' ],
function(Prism, Modernizr, $, Backbone, Router, App) {
this.router = new Router();
this.App = new App();
}
);
一旦它被「墊底」,我該如何使用它? –
就像任何其他模塊一樣:'require('prism');'或者將它作爲依賴包含在'define'的參數中。 –