描述
我试图添加“webpack”构建到一个老项目与 Backbone 和牵线 puppet 。
我收到错误
backbone.marionette.js:3228 Uncaught TypeError: Cannot read property 'radio' of undefined
at constructor._initChannel (backbone.marionette.js:3228)
at new constructor (backbone.marionette.js:3096)
at eval (tzook.js:128)
at Object../frontend-app/tzook.js (main.bundle.js:7754)
at __webpack_require__ (main.bundle.js:79)
at eval (webpack:///multi_(:3000/webpack)-dev-server/client?:2:18)
at Object.0 (main.bundle.js:9043)
at __webpack_require__ (main.bundle.js:79)
at checkDeferredModules (main.bundle.js:46)
at main.bundle.js:152
所以我试着做:
var Backbone = require('backbone'),
babysitter = require('backbone.babysitter'),
wreqr = require('backbone.wreqr');
Backbone.Wreqr = wreqr;
但正如我在backbone.marionette.js
文件中看到的那样,如果我加载自己的 Backbone.js ,这并不重要,因为它加载了自己的版本:/
版本:
"backbone": "1.2.3",
"backbone-forms": "0.14.0",
"backbone.marionette": "^2.4.4",
"backbone.paginator": "~2.0.2",
"backbone.subroute": "^0.4.4",
"backbone.wreqr": "^1.0.0",
(function(root, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! backbone */ "./node_modules/backbone.marionette/node_modules/backbone/backbone.js"), __webpack_require__(/*! underscore */ "./node_modules/underscore/underscore.js"), __webpack_require__(/*! backbone.wreqr */ "./node_modules/backbone.wreqr/lib/backbone.wreqr.js"), __webpack_require__(/*! backbone.babysitter */ "./node_modules/backbone.babysitter/lib/backbone.babysitter.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(Backbone, _) {
return (root.Marionette = root.Mn = factory(root, Backbone, _));
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else { var BabySitter, Wreqr, _, Backbone; }
1条答案
按热度按时间wz8daaqr1#
注意:在Marionette的下一个主要版本v3中,Wreqr将被一个更新的库Radio替换。
您需要在Marionette之前包含backbone.radio作为依赖项