gpt4 book ai didi

data-binding - 由于templateShareable :true?导致SAPUI5错误消息的解决方法

转载 作者:行者123 更新时间:2023-11-30 23:57:15 24 4
gpt4 key购买 nike

自从升级 SAPUI5 1.28.20 后,我收到以下错误消息:

A shared template must be marked with templateShareable:true in the binding info

代码在 MangedObject.js 中,如下所示:

        } else if ( oBindingInfo.templateShareable === MAYBE_SHAREABLE_OR_NOT ) {
// a 'clone' operation implies sharing the template (if templateShareable is not set to false)
oBindingInfo.templateShareable = oCloneBindingInfo.templateShareable = true;
jQuery.sap.log.error("A shared template must be marked with templateShareable:true in the binding info");
}

oBindingInfo.templateShareable 的值为 trueMAYBE_SHAREABLE_OR_NOT 的值为 1。

根据文档,oBindingInfo.templateShareable 的默认值为 true

那么这里有什么问题呢?库中的错误?或者我的代码有什么?另见:https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.base.ManagedObject.html

SAPUI5 1.32.x 版更新

在 1.32.x 版本中,消息已更改为:

A template was reused in a binding, but was already marked as candidate for destroy. You better should declare such a usage with templateShareable:true in the binding configuration. -

但根据文档,默认值仍应为 true:

{boolean} oBindingInfo.templateShareable?, Default: true option to enable that the template will be shared which means that it won't be destroyed or cloned automatically

现在看起来,这会产生一些无休止的加载,我一次又一次地收到这条消息,直到浏览器崩溃。有人知道可能出了什么问题吗?

最佳答案

看起来如果模板是在绑定(bind)之外实例化的,则会出现该消息。示例:

此代码将起作用:

new sap.m.Select({
items : {
path : "/Items",
template : new sap.ui.core.Item({
text : "{Name}"
})
}
})

这段代码似乎产生了消息:

var oTemplate = new sap.ui.core.Item({
text : "{Name}"
})


new sap.m.Select({
items : {
path : "/Items",
template :oTemplate
}
})

这似乎解决了问题:

var oTemplate = new sap.ui.core.Item({
text : "{Name}"
})


new sap.m.Select({
items : {
path : "/Items",
template :oTemplate,
templateShareable : true
}
})

关于data-binding - 由于templateShareable :true?导致SAPUI5错误消息的解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33477355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com