因此,我將PNotify
從bower導出到js
文件夾。我用requirejs
,包括我的圖書館不可能包含要求的PNotify
HTML
<script data-main="assets/js/app" type="text/javascript" src="assets/js/lib/require.js"></script>
我的架構是這樣的:
js
--- app.js
--- lib
------ pnotify.core.js
------ pnotify.desktop.js
------ pnotify.buttons.js
------ pnotify.callbacks.js
------ pnotify.confirm.js
------ pnotify.history.js
------ pnotify.nonblock.js
------ pnotify.reference.js
------ jquery.js
------ ...
我添加主模塊,該模塊是pnotify.core
APP .JS
requirejs.config({
base: '/assets/js',
paths: {
'jQuery': 'lib/jquery.min',
'underscore': 'lib/underscore-min',
'Backbone': 'lib/backbone',
'Modernizr' : 'lib/modernizr',
'PNotify' : 'lib/pnotify.core',
'LoginView' : 'views/login'
},
shim: {
'jQuery': {
exports: '$'
},
'underscore': {
exports: '_'
},
'Backbone': {
exports: 'Backbone'
},
'Modernizr': {
exports: 'Modernizr'
},
'LoginView': {
exports: 'LoginView'
},
'PNotify': {
exports: 'PNotify'
}
}
});
PNotify已加載到我的頁面中。通常情況下,PNotify與requirejs一起工作:https://github.com/sciactive/pnotify#using-pnotify-with-requirejs
我不知道如何導入所有模塊,也許concat這些模塊在一個文件pnotify.min.js?
在這裏,當我打電話下requirejs.config
define(['jQuery', 'underscore', 'Backbone', 'Modernizr', 'LoginView', 'PNotify'], function ($, _, Backbone, Modernizr, LoginView, PNotify) {
$(document).ready(function(){
new PNotify({
title: 'Desktop Notice',
text: 'If you\'ve given me permission, I\'ll appear as a desktop notification. If you haven\'t, I\'ll still appear as a regular PNotify notice.'
});
});
});
我有這樣的錯誤PNotify
對象:Uncaught TypeError: undefined is not a function
上線「新PNotify」 ......
你有一些想法?