【问题标题】:Error occurs when importing framer-motion导入 framer-motion 时出错
【发布时间】:2021-04-11 12:26:06
【问题描述】:

安装 framer-motion 和 从'framer'导入{Frame,useMotionValue,useTransform};。但是,我收到以下错误。

Cannot find module 'framer' or its corresponding type declarations.ts(2307)

【问题讨论】:

  • framer-motion 有自己的 TypeScript 声明,因此您只需安装 framer-motion。你试过yarn add framer-motion吗?告诉我你在 package.json 文件中看到的 framer-motion 版本?你不需要framer,你只需要framer-motion 就可以了。试试this sandboxthis
  • 版本是“framer-motion”:“3.10.6”。

标签: reactjs framer-motion


【解决方案1】:

您安装了 framer-motion 对吗?然后你必须从那个库本身导入!

你这样做:

import { Frame, useMotionValue, useTransform } from "framer-motion"

【讨论】:

  • Yes.Module '"framer-motion"' has no export member 'Frame'.ts(2305)会报错。
  • 然后不要导入它
【解决方案2】:
npm i framer-motion

之后:

import { useMotionValue, useTransform } from "framer-motion"
import { Frame } from "framer"

你误解了“framer-motion”和“framer”

【讨论】:

    猜你喜欢
    • 2021-12-14
    • 2021-12-24
    • 2021-12-30
    • 1970-01-01
    • 2023-02-13
    • 1970-01-01
    • 2021-06-13
    • 2020-12-18
    相关资源
    最近更新 更多