youchant / requirejs-ver

A requirejs plugin for veronica

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

requirejs-ver

veronica 的一个 requirejs 插件,用于加载 widget

使用方法

  • 引入后作为子视图
define([
  'ver!sub-view'
], function (SubView) {

    return {
        views: function () {
            return {
                'sub': {
                    host: '.data-sub',
                    initializer: SubView,
                    options: {
                        data: {}
                    }
                }
            }
        }
    };
});
  • 引入后进行扩展或重写
define([
  'ver!sub-view'
], function (baseFactory) {
    var base = baseFactory.export();

    var originalRender = base.render;
    base.render = function () {
        originalRender.apply(this, Array.prototype.slice.call(arguments));

        // custom code
        console.log('rendered');
    }

    return base;
});

About

A requirejs plugin for veronica


Languages

Language:JavaScript 100.0%