How to develop an Android App project with vue
1. Progress statement
the vue project created through vue-cli has now completed the html page with no data interaction
2. Problem description
in terms of data interaction, I understand that the http request is made with vue-resources as before, and then the page processes the data. But the back-end staff of Android developers said that this is not the case (the back end is also a novice), saying that we have to encapsulate the request of http. It turns out that we are this.$http ("requests like http://www.abc.com/goods") can no longer be written in this way, but request
in another way)."
function toLogin(){
var userName = document.getElementById("userName").value;
var pwd = document.getElementById("pwd").value;
window.WebViewJavascriptBridge.callHandler(
"toLogin"
, {"param": "{userName:"+userName+",pwd:"+pwd+"}"}
, function(responseData) {
}
);
}
3. Question
(1) question 1:
I am rather vague now, and I don"t know if I really want to write that way. When I am online Baidu and consult others, I all say that the development of Android APP is also like the this.$http request, and there is no need to encapsulate
(2) question 2
what is cordova packaging and weex packaging? The normal process is to package after my data exchange?
mixed development, it is generally best to deal with logic separately, and if interaction is really needed, you can define methods to communicate.
(1) looking at your description, it seems that you want to encapsulate the request for Android call. In that case, it certainly needs to be encapsulated, but you can initiate the request directly in h5, handle the logic, and simply interact with Android. At present, this is our development, which basically only involves the problem of calling a few functions.
(2) I haven't used these two, just understand that weex is encapsulated based on vue syntax, packaging we are both Android and ios they deal with, we are only responsible for our own h5 part.
1. A normal http request is fine.
2. The APP packaged with cordova is based on webview, and weex is rendered as a native component.
can also be packaged in APICloud, which we used for previous projects.
1). Call the native login interface and jump to the login page directly. If it is your own H5 module login interface, you can directly call the background interface, and the background database is connected
2). Package the data after interaction
< H2 > question 1 < / H2 >
in fact, you only need to verify whether the http
call of vue.js
can run under Android
environment
.
- Let
Android
provide a WebView
that allows js
to run, and get permission to request from the network
- use
WebView
to load vue.js
page
-
vue.js
page executes http call
- waiting for verification result
if the verification is passed, it does not need to be implemented through the native-js
interface at all. Unless there is an interaction requirement, the js
needs to call the native
interface (if verified, do so again, which is equivalent to TuoDiaoKuzi,FangPi. )
< H2 > question 2 < / H2 >
Cordova
is used to package offline html pages, that is, pages that have been compiled and generated. After packaging, they will be installed on the phone along with Apk. When App runs, these locally installed pages will be read directly. It is generally used with ionic
or Framework7
.
p.s. Weex
is not known yet.
cordova, you deserve