Portlet中的YUI版本冲突问题 [英] YUI Version Conflict Issue in Portlet

查看:87
本文介绍了Portlet中的YUI版本冲突问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从portlet加载yui.js 3.3.0版本文件,但liferay使用3.2.0 yui.js文件,
所以每当我加载该页面时,js错误就会出现

I'm loading yui.js 3.3.0 version file from portlet but liferay its using 3.2.0 yui.js file, so whenever i'm loading that page js errors are coming like

G_ENV._loaded [VERSION]未定义 - yui.js中出现此错误,使用的是3.2.0版本的liferay。

G_ENV._loaded[VERSION] is undefined - this error is coming in yui.js which is liferay using that is 3.2.0 version.

所以它的替换值就像G_ENV._loaded [3.2.0]那样会抛出一个错误becoz我们从portlet加载了3.3.0版本。

so its replacing value like G_ENV._loaded[3.2.0] and that will throw an error becoz we loaded 3.3.0 version from portlet.

我换了在portlet中的yui.js 3.2.0版本文件但它抛出了一些其他的js错误。

I replaced yui.js 3.2.0 version file in portlet but It was throwing some other js errors.

如何在3.2.0中工作相同或者是否有任何更新方法现有版本的yui?

How will it work same in 3.2.0 or Is there any way to update existing version of yui?

这是此行中yui.js的代码抛出错误

This is the code of yui.js in this line its throwing error

                      if (!G_ENV._loaded[VERSION][name]) {
                            missing.push(name);
                        } else {
                            used[name] = true; // probably css
                        }

任何帮助都会被批评,任何人都会遇到这种情况问题。

Any help would be appricated, anyone has faced this kind of problem.

谢谢

推荐答案

升级,更改或覆盖由于两个原因,Liferay中的原生YUI安装非常困难。一,Liferay 6.0的UI框架(Alloy)在YUI 3.2.0上运行。二,本机门户模板将合金ui实例化到全局YUI对象(YUI.AUI)上,这很糟糕,因为它使YUI框架与可怕的实现AUI 紧密耦合。您的浏览器在YUI对象上调用此AUI引用,因为页面正在加载并且在window.onload事件之后。如果你试图替换或修改全局YUI对象,它会搞砸合金,Liferay的UI运行起来。

Upgrading, changing, or overwriting the native YUI installation in Liferay is extremely difficult, because of two reasons. One, Liferay 6.0's UI framework (Alloy) runs on YUI 3.2.0. Two, the native portal template instantiates alloy ui onto the global YUI object (YUI.AUI), which is awful, as it makes the YUI framework tightly coupled to the horrifically implemented AUI. Your browser calls this AUI reference, on the YUI object, as the page is loading and after the window.onload event. If you try to replace or modify the global YUI object, it screws up Alloy, which Liferay's UI runs on.

由于升级是不可能的,下一个最佳选择是引入您想要使用的新YUI模块。另外,你可以尝试使用内置3.4.1的Liferay 6.1 CE,但看起来它还处于测试阶段。

Since upgrading is out of the question, the next best alternative is to bring in just the new YUI modules you want to use. Also, you could try out Liferay 6.1 CE, which has 3.4.1 built in, but it looks like its still in beta testing.

这是一个引入的例子使用YUI 3.4.1中的dom-core模块并在Liferay 6中使用它,它在YUI 3.2.0上运行。我从YUI的文档中得到了关于如何将YUI 2模块变为3的想法( http://yuilibrary.com/yui/docs/yui/yui-loader-ext.html )。要快速找出每个模块的依赖关系,您可以使用YUI的在线配置器 http://yuilibrary.com/yui/configurator /

Here's an example of bringing in and using the dom-core module from YUI 3.4.1 and using it in Liferay 6, which runs on YUI 3.2.0. I got the idea from YUI's docs on how to bring YUI 2 modules into 3 (http://yuilibrary.com/yui/docs/yui/yui-loader-ext.html). To quickly figure out dependencies each module has, you can use YUI's online configurator http://yuilibrary.com/yui/configurator/.

var config = {
ignore : ["skin-sam-overlay","skin-sam-widget","skin-sam-widget-stack","skin-sam-tabview"],
groups: {
    yui341: {
        base: '/js/yui-3.4.1/build/',
        modules:  {
            yui341_yui_base: {
                path: 'yui-base/yui-base.js'
            },
            yui341_oop: {
                path: 'oop/oop.js',
                requires: ['yui341_yui_base']
            },
            yui341_features: {
                path: 'features/features.js',
                requires: ['yui341_yui_base']
            },
            yui341_dom_core: {
                path: 'dom-core/dom-core.js',
                requires: ['yui341_yui_base','yui341_oop','yui341_features']
            }
        }
    }
}
};

YUI(config).use('yui341_dom_core',function(Y){
    //YUI 3.4.1 config modules are now accessable through 'use' call
    console.log(Y.version);  //say hello to the newer version (3.4.1)
    Y.use('dom-core',function(Y){
        //Finally have access to native 3.4.1 module
        console.log(Y.DOM);
    });
});

这篇关于Portlet中的YUI版本冲突问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆