用javascript在码实云平台上,可以在云里编写原生的移动应用。移动应用有时会需要插入一个web网页。这件事非常简单,下面实例中,用Ti.UI.createWebView嵌入了一个网页浏览器webView,用url属性来设定访问的网站。同时也展示了网页浏览器可以按照普通View来设定尺寸位置颜色等等。webView只是一个View,因此我们可以轻易地在页面的表层添加一个文字“码实科技”。
Class.create(Mash5.Widget, {
initialize : function (config, params) {
var container = Ti.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
backgroundColor : '#bbb'
});
this.setContentView(container);
var webview = Ti.UI.createWebView({
url: 'http://m.mash5.cn',
width: '80%',
top: '20dip',
bottom: '20dip',
borderColor: '#888',
borderRadius: dipToPx(20),
backgroundColor: '#000'
});
container.add(webview);
container.add(Ti.UI.createLabel({
text : '码实科技',
color : '#44f',
font : {
fontSize : '50dip',
fontWeight: 'bold'
},
}));
}
})