Sencha touch 2 ST2 ListItem setHtml可以';t获取子节点的值
我有两个模式的“状态”属于:“用户”,我正在学习sencha touch 2名为touchtweets的示例。 这是我的json文件Sencha touch 2 ST2 ListItem setHtml可以';t获取子节点的值,sencha-touch-2,dataview,listitem,Sencha Touch 2,Dataview,Listitem,我有两个模式的“状态”属于:“用户”,我正在学习sencha touch 2名为touchtweets的示例。 这是我的json文件 { "statuses" : [{ "text" : "test", "user" : { "name" : foo, } }] } 官方文件说“当记录更新时,获取文本配置,然后 使用记录的“text”字段调用setText。但我正在尝试setHtml:“user.name”它
{
"statuses" : [{
"text" : "test",
"user" : {
"name" : foo,
}
}]
}
官方文件说“当记录更新时,获取文本配置,然后
使用记录的“text”字段调用setText
。但我正在尝试setHtml:“user.name”它不起作用,我无法理解。
这是我的视图代码
Ext.define('Demo.view.StatusesListItem', {
extend : 'Ext.dataview.component.ListItem',
xtype : 'statuseslistitem',
requires : ['Demo.view.StatusesListItemText', 'Ext.Img'],
config : {
dataMap : {
getText : {
setHtml : 'text', //work well
},
getUserName : {
setHtml : 'user.name', //didn't work
}
},
userName : {
cls : 'username'
},
text : {
cls : 'text'
},
layout : {
type : 'vbox'
}
},
applyUserName : function(config) {
console.log(Ext.factory(config, Ext.Component, this.getUserName()))
return Ext.factory(config, Ext.Component, this.getUserName());
},
applyText : function(config) {
return Ext.factory(config, Sin.view.StatusesListItemText, this.getText());
},
updateTpl : Ext.emptyFn,
});
Ext.define('Demo.view.StatusesListItemText', {
extend : 'Ext.Component',
applyHtml : function(html) {
html = html.replace(/(http:\/\/[^\s]*)/g, "<a class=\"link\" target=\"_blank\" href=\"$1\">$1</a>");
return html;
}
});
Ext.define('Demo.view.StatusesListItem'{
扩展:“Ext.dataview.component.ListItem”,
xtype:'statuseslistitem',
需要:['Demo.view.StatusesListItemText','Ext.Img'],
配置:{
数据映射:{
getText:{
setHtml:'text',//工作正常
},
getUserName:{
setHtml:'user.name',//不起作用
}
},
用户名:{
cls:'用户名'
},
正文:{
cls:“文本”
},
布局:{
类型:“vbox”
}
},
applyUserName:函数(配置){
log(Ext.factory(config,Ext.Component,this.getUserName()))
返回Ext.factory(config,Ext.Component,this.getUserName());
},
applyText:函数(配置){
返回Ext.factory(config,Sin.view.StatusesListItemText,this.getText());
},
updateTpl:Ext.emptyFn,
});
Ext.define('Demo.view.StatusesListItemText'{
扩展:“Ext.Component”,
applyHtml:函数(html){
html=html.replace(/(http:\/\/[^\s]*)/g,“”;
返回html;
}
});
setHtml无法获取子节点的值
有人能帮我吗?Thx您的时间不幸的是,这是不可能的 绕过它的一种方法是将
getUserName
的值设置为user
,然后更改applyUserName
方法以访问name
属性
applyUserName : function(config) {
var name = config.name;
return Ext.factory(name, Ext.Component, this.getUserName());
}
Thx,但我不明白,我已经更改了我的代码dataMap:{getUserName:{setHtml:'user',},},和applyUserName函数,但是在console.log中config.name返回未定义,你能帮我吗