Extjs 从内部设置ViewModel数据值';不要更新视图
我需要从Extjs 从内部设置ViewModel数据值';不要更新视图,extjs,extjs5,Extjs,Extjs5,我需要从setTimeout回调函数中更新我的ViewModel数据,但它不起作用。看起来我遇到了一个类似于当我需要在Angular outside Angular中更新数据值,然后需要调用$scope.apply(),但以ExtJS的方式时所发生的问题 代码如下: Ext.define('Web.view.taskbar.clock.ClockController', { extend: 'Ext.app.ViewController', alias: 'controller
setTimeout
回调函数中更新我的ViewModel
数据,但它不起作用。看起来我遇到了一个类似于当我需要在Angular outside Angular中更新数据值,然后需要调用$scope.apply()
,但以ExtJS的方式时所发生的问题
代码如下:
Ext.define('Web.view.taskbar.clock.ClockController', {
extend: 'Ext.app.ViewController',
alias: 'controller.taskbar-clock',
init: function() {
var me = this;
// this works
var time = new Date();
me.getViewModel().data.time = time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds();
// this doesn't work
var timer = function() {
setTimeout(function() {
var time = new Date();
me.getViewModel().data.time = time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds();
timer();
}, 1000);
};
timer();
}
});
编辑:
更新的工作代码
Ext.define('Web.view.taskbar.clock.ClockController', {
extend: 'Ext.app.ViewController',
alias: 'controller.taskbar-clock',
init: function() {
var vm = this.getViewModel();
var timer = function() {
setTimeout(function() {
var time = new Date();
vm.set('time', time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds());
timer();
}, 1000);
}
timer();
}
});
您需要调用setter方法:
vm.set('time','x')代码>您需要调用setter方法:
vm.set('time','x')代码>您需要调用setter方法:
vm.set('time','x')代码>您需要调用setter方法:
vm.set('time','x')代码>我忘了提到:ExtJS 5.1我忘了提到:ExtJS 5.1我忘了提到:ExtJS 5.1我忘了提到:ExtJS 5.1