我可以为Ubuntu手机开发混合原生/ HTML5应用程序吗?

我可以开发一个与Ubuntu手机中的本机API和HTML5结合使用的混合应用程序吗?

我知道可以开发本机应用程序或HTML5应用程序。

但是,我想知道开发一个在Ubuntu Phone中具有HTML5 UI(混合)的本机应用程序。

我不确定你对“混合”(一个显示webapp的C ++应用程序?在C ++ / QML / javascript之间分发应用程序代码?)的意思,但你可以使用WebView组件在qml应用程序上显示网页/ webapp 。 这应该适用于Ubuntu手机。

拿这个简单的应用程序组成:“app.qml”,“app.html”和“app.js”(是的,我知道,这个“应用程序”非常蹩脚……)。 这只是用qmlviewer测试的,所以如果你试图通过IDE运行它,你可能需要根据使用的相对路径修改一些东西。

app.qml

 import QtQuick 1.0 import QtWebKit 1.0 Rectangle { width: 800 height: 600 WebView { url: "app.html" anchors.fill: parent preferredWidth: 800 preferredHeight: 600 smooth: false settings.developerExtrasEnabled : true settings.javascriptEnabled: true } } 

app.html

     Hi    Click me!    

app.js

 var x = document.getElementById("test_me"); x.onclick = function(){ console.log("Hi there"); new_elem = document.createElement("h2"); new_elem.textContent = "Hi there!"; document.getElementsByTagName("body")[0].appendChild(new_elem); }; 

希望能帮助到你。