我不熟悉跨平台的Titanium,也不熟悉合金MVC框架。
我在index.xml中创建了一个按钮,如下所示:
<Alloy>
<Button id="button">Click Me</Button>
</Alloy>但现在我想知道如何在iPhone上显示标题"Click Me“,在iPad上显示标题"Submit”。
我需要在哪里写条件?在index.xml、index.js或index.tss中?
发布于 2013-04-28 23:20:50
有几种方法可以做到这一点,在index.xml文件中如下所示:
<Alloy>
<Button formFactor="handheld" id="button">Click Me</Button>
<Button formFactor="tablet" id="button">Submit</Button>
</Alloy>或者在index.js中如下所示:
if(Alloy.isHandheld) {
$.button.title = "Click Me";
}
if(Alloy.isTablet) {
$.button.title = "Submit";
}或者在样式文件中,index.tss如下所示:
"#button[formFactor=handheld]" : {
title : "Click Me"
},
"#button[formFactor=tablet]" : {
title : "Submit"
}https://stackoverflow.com/questions/16260213
复制相似问题