简体   繁体   中英

vue3 typescript question. what type is lazy-loading vue-router?

export default {
  path: '/about',
  name: 'About',
  // route level code-splitting
  // this generates a separate chunk (about.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  component: (): Promise<any> => import(/* webpackChunkName: "about" */ '../../views/About.vue'),
};

I am using Vue3 & vue-router & eslint air-bnb,

the eslint check says i need to set the right type, how do i check the type and what type should fill to avoid the eslint check? many thanks在此处输入图像描述

The correct return type is Promise<RouteComponent>

import { RouteComponent } from "vue-router";

export default {
  path: '/about',
  name: 'About',
  component: (): Promise<RouteComponent> => import('../../views/About.vue'),
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM