先到插件網站找這個插件
html
插件網站地址 http://cordova.apache.org/plugins/ apache
而後找到了這個npm
插件 地址是https://www.npmjs.com/package/cordova-plugin-splashscreen
網絡
經過命令行安裝插件cordova plugin add cordova-plugin-splashscreenapp
安裝完以後你發現項目多了點東西好比
eclipse
仔細觀察下項目的目錄結構,你會發現ide
screen.png對應的就是歡迎頁面。測試
你能夠將本身的screen.png覆蓋掉全部的,固然大小最好按照原來的各個尺寸。。網站
用eclipse運行一下。結果就ok了。ui
再說下插件的幾個屬性
SplashScreen (string). The resource name which is used for the displaying splash screen. Different platforms use values for this.
<preference name="SplashScreen" value="resourcename" />
AutoHideSplashScreen (boolean, default to true
). Indicates wherether hide splash screen automatically or not. Splash screen hidden after amount of time specified in the SplashScreenDelay
preference.
<preference name="AutoHideSplashScreen" value="true" />
SplashScreenDelay (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
<preference name="SplashScreenDelay" value="3000" />
在config.xml中能夠配置
<preference name="SplashScreen" value="resourcename" />
resourcename指定的是資源的文件名。假如咱們這裏不設置。
默認就是
<preference name="SplashScreen" value="screen" /> 爲了作個測試,我在各個文件夾下添加了screen1.png 而後在config.xml中指定 <preference name="SplashScreen" value="screen1" /> 再運行一下發現歡迎頁面變成了screen1.png圖片
<preference name="SplashScreenDelay" value="3000" />
對應這個設置,若是咱們首次進入首頁會比較慢,好比首頁指定的是非本地的html,指定的是一個網絡地址的文件,咱們能夠考慮將value設置爲100000 也便是10秒。而後再在
設備準備好以後
執行navigator.splashscreen.hide(); 例子以下
var app = { // Application Constructor initialize: function() { this.bindEvents(); }, // Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicitly call 'app.receivedEvent(...);' onDeviceReady: function() { //app.receivedEvent('deviceready'); navigator.splashscreen.hide(); },