标签:vue 使用 env add turn path tom 代码 listener cat
主要配置代码:
new PrerenderSPAPlugin({ staticDir: path.join(__dirname, ‘dist‘), routes: [‘/‘, ‘/introduction‘, ‘/application‘, ‘/download‘], postProcess: function (context) { context.html = context.html.replace( /<\/head>/i, `<script> document.addEventListener("DOMContentLoaded", function (event) { document.getElementById(‘landing‘).style.display = ‘none‘; }) </script> </head>` ) return context } }),
html
<div id="landing"> <img id="landing-img" src="/loading-bars.svg" alt="landing"> </div>
css
#landing { position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: #fff; z-index: 3000; } #landing-img { position: absolute; width: 60px; left: 50%; top: 40%; margin-left: -20px; }
main.js
new Vue({ router, store, render: h => h(App), mounted () { if (process.env.NODE_ENV !== ‘production‘) { document.getElementById(‘landing‘).style.display = ‘none‘ } } }).$mount(‘#app‘)
Vue 使用 prerender-spa-plugin 添加loading
标签:vue 使用 env add turn path tom 代码 listener cat
原文地址:https://www.cnblogs.com/savokiss/p/9457176.html