所以,我PNotify
从凉亭导出到js
文件夹。我requirejs
用来包含我的库
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
我不知道如何导入所有模块,也许将这些模块连接到一个文件 pnotify.min.js 中?
在这里,当我调用PNotify
下的对象时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.'
});
});
});
我有这个错误:Uncaught TypeError: undefined is not a function
在“新 PNotify”这一行上......
你有什么想法吗?