鍍金池/ 問(wèn)答/HTML/ Vue全家桶解析時(shí)間太長(zhǎng)

Vue全家桶解析時(shí)間太長(zhǎng)

clipboard.png

TIPS: 請(qǐng)求為本地, 網(wǎng)絡(luò)很快, 主要是JS 代碼解析阻塞導(dǎo)致白屏?xí)r間過(guò)久

如圖所示, javascript 在手機(jī)瀏覽器中加載速度過(guò)慢, 加上網(wǎng)絡(luò)請(qǐng)求等平常會(huì)達(dá)到2s左右的時(shí)間才能展示首頁(yè), 請(qǐng)問(wèn)各位大佬有什么解決方案嗎

以嘗試以下方案
  1. 按需加載router
  2. 第三方庫(kù)打入一個(gè)包
  3. 基本代碼優(yōu)化
想用但是條件不予許
  1. SSR
回答
編輯回答
笨小蛋
// router.js
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export function createRouter () {
  return new Router({
    mode: 'history',
    routes: [
      { path: '/', component: () => import('./components/Home.vue') },
      { path: '/item/:id', component: () => import('./components/Item.vue') }
    ]
  })
}
2018年4月21日 20:08