项目首页中有些组件在第一次加载的时候会很慢,我们可以使用vue3内置的<compont>标签实现懒加载具体代码如下:
模板:
<template> <component :is="bigComponent" /> </template>
JS:
mounted() { this.$nextTick(()=>{ import('path').then((component) => { this.bigComponent = component.default }) }) }
项目首页中有些组件在第一次加载的时候会很慢,我们可以使用vue3内置的<compont>标签实现懒加载具体代码如下:
模板:
<template> <component :is="bigComponent" /> </template>
JS:
mounted() { this.$nextTick(()=>{ import('path').then((component) => { this.bigComponent = component.default }) }) }