How does Android call the methods method in vue?

I wrote a method in methods in vue, which is exposed to Android in mounted, as follows:

methods: {

outGoodsResult(val){
    alert("ceshi")
    alert(val)
}

}

mounted () {

window.outGoodsResult = self.outGoodsResult

}
he said it was called, but my alert didn"t pop up the data, or did he not call it? Before, he said there was no change to the code, but I didn"t have it either. Is there any other way for Android to call the method in vue? I have also tried to write this way as follows:
window ["outGoodsResult"] = function (val) {

alert("ceshi")
alert(val)

}
I can"t write it like this. What"s the reason, please?


has this been added in the native? if not, the alert box in JS will not pop up

// WebChromeClient:WebViewJavaScript
mWebView.setWebChromeClient(new WebChromeClient());

are you mixed developers? don't you all have to go through jsbridge to bridge? I just got in touch with mixed development, too. We use dsbridge , which is not bad. You can try


.

1.JS Code

<script type="text/javascript">
    //<![CDATA[

    window.onload = function() {
        var MyComponent = Vue.extend({
            methods: {
                vfunc: function() {
                    alert();
                }
            },
            created() {
                window.vue = this
            }
        });

        var vm = new Vue({
            el: '-sharpapp',
            components: {
                'my-component': MyComponent
            }
        });
        window.vm = vm;

    } //]]>

    function callVueJsMethod() {
        window.vue.vfunc();
        //window.vm.$refs.foo.vfunc();
    }
</script>

2.Java Code

  • allow dialog boxes such as alert to pop up:
WebView.setWebViewClient(new WebViewClient());
WebView.setWebChromeClient(new WebChromeClient());
  • call the JS method:
WebView.loadUrl("javascript: callVueJsMethod()");

or

WebView.evaluateJavascript("javascript: callVueJsMethod()", null);

p.s.JSBridge has another problem. Portal:

  1. github:lzyzsd/JsBridge (Android)
  2. github:marcuswestin/WebViewJavascriptBridge (iOS)

maybe your Android webview does not support alert.
Let him take a look at it or call other methods here to test whether the function has been called

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf1980-31daf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf1980-31daf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?