xiaoweipeng
V2EX  ›  React

这个为啥报错呀

  •  
  •   xiaoweipeng · Feb 26, 2023 · 3158 views
    This topic created in 1345 days ago, the information mentioned may be changed or developed.

    这个为啥报错呀

    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 replies  •  2023-02-27 02:23:12 +08:00
    anonymous2351d00
    anonymous2351d00
    Feb 26, 2023
    1
    要不要试试引入一下

    import React from 'react';
    xiaoweipeng
    xiaoweipeng
    OP
    Feb 27, 2023
    2
    试过了,不行
    xiaoweipeng
    xiaoweipeng
    OP
    Feb 27, 2023
    3
    @anonymous2351d00 试过了,不行
    gausszhou
    gausszhou
    Feb 27, 2023
    4
    空格啊
    ruoxie
    ruoxie
    Feb 27, 2023 via iPhone
    5
    element: Home
    des
    des
    Feb 27, 2023
    6
    你需要将文件名从 ts 改名为 tsx
    IvanLi127
    IvanLi127
    Feb 27, 2023 via Android
    7
    楼上正解,文件名不对
    xiaoweipeng
    xiaoweipeng
    OP
    Feb 27, 2023
    8
    @des 可以,感谢大佬
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1508 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:01 · PVG 07:01 · LAX 15:01 · JFK 18:01
    ♥ Do have faith in what you're doing.