App embedded Vue h5, Android and iOS intercept H5 click events

Source: Internet
Author: User

Android and iOS intercept H5 Click events, this function event must be a burst in the window

Android and iOS intercept common H5 functions:

1 <div onclick = "show (), Window.android.show ()" ></div>2 <script>3     function Show () {
If you need to pass a value, you can add a parameter to the show and pass the value directly in the Click event above 4 alert (1)5 } 6 </script>

The Vue function does not leak directly under window, Vue's Click event is @click, so the above-mentioned app is blocked

Android and iOS intercept vue click events:

<div id= "box" @click = "show (' aaaa '), window.android.show (' aaaa ')" ></div>//in parentheses for the contents of the parameter, the first show is for iOS value, When clicked triggers the function defined in window, iOS intercepts the Zhi function directly, and Android can intercept the function defined in Vue directly <script src= "Vue.js" ></script> <script >functionZhi (a) {//define a burst to window function, placed in the Click event, the iOS intercept function is intercepted this burst to window functionConsole.log (a)}NewVue ({el:"#box", data:{}, methods:{show:function(a) {zhi (a); //A is a parameter that can be used to transmit values to iOS and AndroidAlert (1); }        }    })</script>

App embedded Vue h5, Android and iOS intercept H5 click events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.