简体   繁体   English

未捕获的ReferenceError:模块未定义RequireJS

[英]Uncaught ReferenceError: module is not defined RequireJS

I have successfuly implemented Froala to angular using RequireJS, but there occurs 2 problems. 我已经使用RequireJS成功地将Froala实现为有角度的,但是出现了2个问题。

If i want to add another plugin of froala (let's say url input) it returns an error 如果我想添加另一个froala插件(比如说url输入),则会返回错误

Uncaught ReferenceError: module is not defined 未捕获的ReferenceError:模块未定义

Cannot get it, if the main plugin froala does not return any errors, why does froala plugins return since coding is the same? 无法获取它,如果主插件froala不返回任何错误,为什么froala插件由于编码相同而返回?

main.js main.js

 /*jshint unused: vars */ require.config({ paths: { angular: '../../bower_components/angular/angular', 'angular-animate': '../../bower_components/angular-animate/angular-animate', 'angular-cookies': '../../bower_components/angular-cookies/angular-cookies', 'angular-mocks': '../../bower_components/angular-mocks/angular-mocks', 'angular-resource': '../../bower_components/angular-resource/angular-resource', 'angular-route': '../../bower_components/angular-route/angular-route', 'angular-sanitize': '../../bower_components/angular-sanitize/angular-sanitize', 'angular-touch': '../../bower_components/angular-touch/angular-touch', 'ui-router': '../../bower_components/angular-ui-router/release/angular-ui-router.min', jquery: '../../bower_components/jquery/dist/jquery', bootstrap: '../../bower_components/bootstrap/dist/js/bootstrap', 'angular-ui-router': '../../bower_components/angular-ui-router/release/angular-ui-router', 'froala-editor': '../../bower_components/froala-wysiwyg-editor/js/froala_editor.min', 'froala-pl': '../../bower_components/froala-wysiwyg-editor/js/languages/pl', froala: '../../bower_components/angular-froala/src/angular-froala', 'froala-sanitize': '../../bower_components/angular-froala/src/froala-sanitize', 'froala_url': '../../bower_components/froala-wysiwyg-editor/js/plugins/url.min' }, shim: { angular: { exports: 'angular' }, 'froala-pl': [ 'froala-editor' ], froala: [ 'froala_url', 'angular', 'froala-pl', 'froala-sanitize' ], 'froala-sanitize': [ 'angular' ], 'angular-route': [ 'angular' ], 'angular-cookies': [ 'angular' ], 'angular-sanitize': [ 'angular' ], 'angular-resource': [ 'angular' ], 'angular-animate': [ 'angular' ], 'angular-touch': [ 'angular' ], 'ui-router': [ 'angular' ], 'angular-mocks': { deps: [ 'angular' ], exports: 'angular.mock' }, bootstrap: [ 'jquery' ] }, priority: [ 'angular' ], packages: [ ] }); //http://code.angularjs.org/1.2.1/docs/guide/bootstrap#overview_deferred-bootstrap window.name = 'NG_DEFER_BOOTSTRAP!'; require([ 'angular', 'app', 'angular-route', 'angular-cookies', 'angular-sanitize', 'angular-resource', 'angular-animate', 'angular-touch', 'ui-router', 'jquery', 'bootstrap', 'froala', 'froala_url' ], function(angular, app, ngRoutes, ngCookies, ngSanitize, ngResource, ngAnimate, ngTouch) { 'use strict'; /* jshint ignore:start */ var $html = angular.element(document.getElementsByTagName('html')[0]); /* jshint ignore:end */ angular.element().ready(function() { angular.resumeBootstrap([app.name]); }); }); 

app.js app.js

 /*jshint unused: vars */ define(['angular', 'controllers/main', 'controllers/admin', 'services/rest', 'services/auth', 'controllers/pages', 'controllers/dashboard']/*deps*/, function (angular, MainCtrl, LoginCtrl, RESTFactory, AuthFactory, PagesCtrl, DashboardCtrl)/*invoke*/ { 'use strict'; /** * @ngdoc overview * @name cmsApp * @description * # cmsApp * * Main module of the application. */ return angular .module('cmsApp', ['cmsApp.controllers.MainCtrl', 'cmsApp.controllers.AdminCtrl', 'cmsApp.services.REST', 'cmsApp.services.Auth', 'cmsApp.controllers.PagesCtrl', 'cmsApp.controllers.DashboardCtrl', /*angJSDeps*/ 'ngCookies', 'ngResource', 'ngSanitize', 'ngRoute', 'ngAnimate', 'ngTouch', 'ui.router', 'froala' ]) .config(function ($urlRouterProvider, $stateProvider) { $urlRouterProvider.otherwise("/"); $stateProvider .state('main', { url: '/', templateUrl: 'views/main.html', controller: 'MainCtrl', controllerAs: 'main' }) .state('dashboard', { url: '/dashboard', templateUrl: 'views/dashboard/index.html', resolve: { authenticate: authenticate }, controller: 'DashboardCtrl', controllerAs: 'dashboard' }) .state('dashboard.subpage', { url: '/page/:id', templateUrl: 'views/dashboard/pages/edit.html', params: { id: null } }) .state('admin', { url: '/admin', templateUrl: 'views/admin.html', controller: 'AdminCtrl', controllerAs: 'admin' }); function authenticate(Auth, $state, $timeout) { var Auth = Auth.isLogged(); return Auth.then(function(response){ var data = response.data; if(data.logged_in == false) { $timeout(function(event) { $state.go('admin'); }, 10); } }); } }); }); 

fraola_url.min.js fraola_url.min.js

 /*! * froala_editor v2.0.1 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms * Copyright 2014-2015 Froala Labs */ ! function(a) { "function" == typeof define && define.amd ? module.exports = function(b, c) { return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c } : a(jQuery) }(function(a) { "use strict"; a.extend(a.FroalaEditor.DEFAULTS, {}), a.FroalaEditor.URLRegEx = /(\\s|^|>)((http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+(\\.[a-zA-Z]{2,3})?(:\\d*)?(\\/[^\\s<]*)?)(\\s|$|<)/gi, a.FroalaEditor.PLUGINS.url = function(b) { function c(d) { d.each(function() { if ("IFRAME" != this.tagName) if (3 == this.nodeType) { var d = this.textContent.replace(/&nbsp;/gi, ""); a.FroalaEditor.URLRegEx.test(d) && (a(this).before(d.replace(a.FroalaEditor.URLRegEx, '$1<a href="$2">$2</a>$7')), a(this).remove()) } else 1 == this.nodeType && ["A", "BUTTON", "TEXTAREA"].indexOf(this.tagName) < 0 && c(b.node.contents(this)) }) } function d() { b.events.on("paste.afterCleanup", function(b) { return a.FroalaEditor.URLRegEx.test(b) ? b.replace(a.FroalaEditor.URLRegEx, '$1<a href="$2">$2</a>$7') : void 0 }), b.events.on("keyup", function(d) { var e = d.which; (e == a.FroalaEditor.KEYCODE.ENTER || e == a.FroalaEditor.KEYCODE.SPACE) && c(b.node.contents(b.$el.get(0))) }), b.events.on("keydown", function(c) { var d = c.which; if (d == a.FroalaEditor.KEYCODE.ENTER) { var e = b.selection.element(); if (("A" == e.tagName || a(e).parents("a").length) && b.selection.info(e).atEnd) return c.stopImmediatePropagation(), "A" !== e.tagName && (e = a(e).parents("a")[0]), a(e).after("&nbsp;" + a.FroalaEditor.MARKERS), b.selection.restore(), !1 } }) } return { _init: d } } }); 

Shims configuration 垫片配置

 'froala-editor': { deps: ['jquery'] }, 'froala-sanitize': { deps: [ 'angular' ] }, froala: { deps: [ 'angular', 'froala-editor', 'froala-pl', 'froala-sanitize' ] }, 'colors': { deps: [ 'jquery', 'froala-editor' ] } 

编辑器存档中有一个示例与RequireJS一起使用: https : //github.com/froala/wysiwyg-editor/blob/master/html/require_js/index.html#L49

“ bower angular-froala”还会自动使用错误的repo插件安装“ froala-wysiwyg-editor”,我不得不用那里的源替换整个插件: https : //github.com/froala/wysiwyg-editor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BackboneJS,RequireJS-未捕获的ReferenceError:未定义$ - BackboneJS, RequireJS - Uncaught ReferenceError: $ is not defined 未捕获的ReferenceError:模块未定义 - Uncaught ReferenceError: module is not defined 页面刷新后RequireJS未捕获的ReferenceError:$未定义 - RequireJS after page refresh Uncaught ReferenceError: $ is not defined 初始化程序抛出错误:未捕获ReferenceError:模块未定义 - Initializers throwing error: Uncaught ReferenceError: module is not defined 未捕获ReferenceError:未在控制器,模块和路由中定义应用 - Uncaught ReferenceError: app is not defined in controller, module, and route 未捕获的ReferenceError:未为导入的模块定义值 - Uncaught ReferenceError: value is not defined for imported module “类型:模块” - 未捕获的 ReferenceError:需要未定义 - “type: module” - Uncaught ReferenceError: require is not defined 从node.js开始获取错误Uncaught ReferenceError:模块未定义,而Uncaught ReferenceError:require未定义 - Starting off in node.js getting errors Uncaught ReferenceError: module is not defined, and Uncaught ReferenceError: require is not defined 错误:未捕获的 ReferenceError:使用 module.export 时未定义模块 - Error: Uncaught ReferenceError: module is not defined when using module.export 未捕获的 ReferenceError ReferenceError:未定义问题 - Uncaught ReferenceError ReferenceError: question is not defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM