Alert doesn't work in ios, I don't know why, so I wrote a pop-up box, okaymethods: {
_IsIOS(){ // Check if it is aN iPhone
if (/(iPhone|iPad|iPod|iOS)/i.test(window.navigator.userAgent)) {
return true;
} else {
return false; }},_IsAndroid(){ // Check whether it is Android
if (/(Android|Adr)/i.test(window.navigator.userAgent)) {
return true;
} else {
return false; }},share(){ // Click the button method
if (this._IsIOS()) {
try{
// WebKit is available in ios
// listen for the share function in ios
// If you want to set the parameters, you can't listen to them
window.webkit.messageHandlers.share.postMessage("11111");
}catch(err){
this.$toast({text: "Call exception"}); // This is the popbox function I wrapped myself
return; }}else if (this._IsAndroid()) {
try{
// Define the share function in Android
window.share.share("11111");
}catch(err){
this.$toast({text: "Call exception"}); // This is the popbox function I wrapped myself
return; }}}}Copy the code