requirejs如何将kindEditor引进来


因为 kindEditor 不是 AMD 写法,那么我如何使用 requirejs kindEditor 引入呢?

main.js 里面


 path: {
    'kindEditor': 'xxxx',
    'zh_CN': 'xxxxxx',
},
shim: {
    'zh_CN': ['kindEditor']
}

directive 里面:


 define(['kindEditor', 'zh_CN'], function () {
    var writeTaskDirective = angular.module('writeTaskDirective', []);
    writeTaskDirective.directive('writeTask', function ($window) {
        return {
            restrict: 'EA',
            template: '<textarea id="editor_id" name="content" style="width:700px;height:300px;">Hml</textarea>',
             replace: true,
                link: function (scope, ele, attr) {
                    KindEditor.ready(function(K) {
                        $window.editor = K.create('textarea[name="content"]');
                    });
                }
        }
    })
})

虽然是异步加载进来了 kindEditor , zh_CN ,同时 kindEditor zh_CN 前面。但是仍然不起作用

requirejs JavaScript

舔胸就是好 9 years, 2 months ago

直接required(“xxxxx”) 引进全局

kagura酱 answered 9 years, 2 months ago

Your Answer