我的环境是 titanim 6.0.1.GA
Android 上不显示标签,而 iOS 上正确显示标签。
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
children:[Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
})]
});
它在 Android/iOS 上都运行良好
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
});
var label = Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
});
descriptionView.add(label)
我只是想知道使用 children 对 andorid 来说是不好的行为吗? 然而,有时简化代码非常有用。
有没有人在Android上成功使用children
??
最佳答案
根据钛 API,“Children”属性是只读属性,不应用于设置数据。它被认为是好运,因为它适用于 IOS,但对于 Android,我们需要具体说明代码。
我绝不会建议您使用这种编码风格来简化代码,而是您可以使用以下方法来简化和内存有效的方式:
var descriptionView = Ti.UI.createView({
height:'100%',width:'100%'
});
descriptionView.add(Ti.UI.createLabel({
wordWrap :true,top:0,
color:'black',
text:"my label",
}));
祝你好运, 干杯
关于android - 属性 `children` 不适用于 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42464479/