gpt4 book ai didi

来自 Ext.app.Controller 的 Extjs-6 MVVM 架构数据绑定(bind)?

转载 作者:行者123 更新时间:2023-12-03 10:35:25 27 4
gpt4 key购买 nike

我正在使用 MVVM architectureExtjs-6在我的应用程序中。我的 Controller 如下(注意 extend: 'Ext.app.Controller' ):

Ext.define('App.controller.gt.Point', {
extend: 'Ext.app.Controller',
myProp: {
x: 'x',
y: 'y'
},
init: function()
{
...
},
activateDrawing: function()
{
...
// I want to send myProp to 'App.view.gt.Point' view and
// it(myProp) use binding
var pointWin = Ext.create('App.view.gt.Point', {});
}
});

如果 activateDrawing被调用, Controller 显示一个窗口( App.view.gt.Point View )。这个窗口类如下:
Ext.define('App.view.gt.Point', {
extend: 'Ext.window.Window',
...
controller: 'gt-point',
viewModel: 'gt-point',
items: [{
xtype: 'form',
items: [{
xtype: 'numberfield',
fieldLabel: 'X',

/*
* I want to bind the numberfield with myProp.x
*/
bind: '{myProp.x}',

}, {
xtype: 'numberfield',
fieldLabel: 'Y',

/*
* I want to bind the numberfield with myProp.y
*/
bind: '{myProp.y}',

}]
}],
buttons: [{text: 'OK', action: 'OK', handler: 'onOk'}],
...
});

如果数字字段 xy改,我要自动改 myProb.xmyProb.y .如何实现这个问题?

最佳答案

数据绑定(bind)和 ViewController/Controller 没有任何关系,没有 Controller 也可以进行数据绑定(bind),只需要一个 ViewModel。

绑定(bind)配置没有正确定义,它们就像 XTemplate:

bind : '{myProp.y}'

假设您的 ViewModel 中有 myProp,如下所示:
data : {
myProp : {
x : 'foo',
y : 'bar'
}
}

关于来自 Ext.app.Controller 的 Extjs-6 MVVM 架构数据绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31784443/

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