懶加載
路由: {
? ? path: '/report',
? ? name: 'report',
? ? component: resolve => require(['./reportMonitoring/index.vue'], resolve) // 懶加載
? }]
組件:
components: {
? ? ? caseDistribute: resolve => require(['./subComponents/caseDistribute'], resolve), // 懶加載
}
Vue :src 綁定綁定的圖片目錄須放在static目錄片酝,否則不是顯示圖片
Vue 全局事件監(jiān)聽(tīng)(跨組件)
that.$event.$emit('changeId',data.casePhaseId)
this.$event.$on('changeId',(val)=>{
that.activeName=val
})
},
Vue.prototype.$event = new Vue()
如果出現(xiàn)Do not use built-in or reserved HTML elements as component id警告:
處理方式這樣的報(bào)錯(cuò)原因是因?yàn)樵贏pp.vue父組件里有標(biāo)簽舞骆,有重名了宣决。所以要把原來(lái)的標(biāo)簽名換掉沧奴,例:翎碑。這里盡量不要設(shè)置為component辅愿。
這樣的報(bào)錯(cuò)還有一個(gè)點(diǎn)就是旭等,在子組件里使用console.log(msg)句携。在控制臺(tái)是接收不到父組件的參數(shù)的琅豆∮洳颍控制臺(tái)會(huì)顯示:undefault