2015-12-18 39 views

回答

2

有趣的問題和一個好主意,以顯示其他信息。我只是做了一個測試,它的工作原理是使用這個插件:

https://www.npmjs.com/package/cordova-plugin-splashscreen

https://www.npmjs.com/package/cordova-plugin-x-toast

科爾多瓦deviceready事件後,只要致電:

navigator.splashscreen.show(); 

,然後你的麪包,在這裏從文檔中取出示例:

window.plugins.toast.showWithOptions(
      { 
       message: "hey there", 
       duration: "short", 
       position: "bottom", 
       addPixelsY: -40, // (optional) added a negative value to move it up a bit (default 0) 
       data: {} // (optional) pass in a JSON object here (it will be sent back in the success callback below) 
      }, 
      // implement the success callback 
      function(result) { 
       if (result && result.event) { 
        console.log("The toast was tapped"); 
        console.log("Event: " + result.event); // will be defined, with a value of "touch" when it was tapped by the user 
        console.log("Message: " + result.message); // will be equal to the message you passed in 
        console.log("data.foo: " + result.data.foo); // .. retrieve passed in data here 
       } else { 
        console.log("The toast has been shown"); 
       } 
      } 
     ); 
+0

我嘗試過更好,更簡單的方法。請在下面找到我的答案。 –

0

這樣做的最簡單的方法是將吐司代碼保留在設備就緒功能中。因此,當應用程序啓動時,消息將沿着閃屏顯示。

document.addEventListener("deviceready", onDeviceReady, false); 
    function onDeviceReady() { 
     // write your code here 
    }