V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xiaoweipeng
V2EX  ›  React

这个为啥报错呀

  •  
  •   xiaoweipeng · 2023-02-26 23:37:22 +08:00 · 1538 次点击
    这是一个创建于 416 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这个为啥报错呀

    import type { RouteObject } from 'react-router-dom'
    import Home from '@/pages/home'
    
    const routes: RouteObject[] = [
      {
        path: '/',
        element: <Home />
      }
    ]
    
    export default routes
    

    ✘ [ERROR] Expected ">" but found "/"

    src/router/routes.ts:8:19: 8 │ element: <Home /> │ ^ ╵ >

    Build failed with 1 error: src/router/routes.ts:8:19: ERROR: Expected ">" but found "/"

    8 条回复    2023-02-27 02:23:12 +08:00
    anonymous2351d00
        1
    anonymous2351d00  
       2023-02-26 23:39:28 +08:00
    要不要试试引入一下

    import React from 'react';
    xiaoweipeng
        2
    xiaoweipeng  
    OP
       2023-02-27 00:10:01 +08:00
    试过了,不行
    xiaoweipeng
        3
    xiaoweipeng  
    OP
       2023-02-27 00:10:29 +08:00
    @anonymous2351d00 试过了,不行
    gausszhou
        4
    gausszhou  
       2023-02-27 01:02:45 +08:00
    空格啊
    ruoxie
        5
    ruoxie  
       2023-02-27 01:09:08 +08:00 via iPhone
    element: Home
    des
        6
    des  
       2023-02-27 01:35:07 +08:00
    你需要将文件名从 ts 改名为 tsx
    IvanLi127
        7
    IvanLi127  
       2023-02-27 01:48:53 +08:00 via Android
    楼上正解,文件名不对
    xiaoweipeng
        8
    xiaoweipeng  
    OP
       2023-02-27 02:23:12 +08:00
    @des 可以,感谢大佬
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5331 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:48 · PVG 16:48 · LAX 01:48 · JFK 04:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.