Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

javascript - 如何在React JS中传递import as props参数(How to pass import as props parameters in React JS)

I use react-lotties and i want to put differents animations in many div changing only the url of lotties

(我使用react-lotties,并且我想在许多div中放置不同的动画,仅更改Lotty的网址)

I am a react beginner, be kind please :)

(我是一名初学者,请好心:))

this is my script :

(这是我的脚本:)

  • My lotties Component :

    (我的彩票组件:)

    import React, { Component } from "react"
    import Lottie from "react-lottie"
    import animationData from "./lotties1.json"
    import animationData from "./lotties2.json"
    import animationData from "./lotties3.json"
    import "./lotties.css"

    class LottiesC extends Component {
      render() {
        const defaultOptions = {
          loop: true,
          autoplay: true,
          animationData: animationData,
          rendererSettings: {
            preserveAspectRatio: "xMidYMid slice",
          },
        }

        return (
          <div className="x">
            <Lottie options={defaultOptions} height={600} width={600} />
          </div>
        )
      }
    }

    export default LottiesC

-My index.js Component:

(-我的index.js组件:)


       import React from "react"
        import Navigation from "../components/Navigation"
        import LottieControl from "../components/LottiesC"

        const index = () => {
          return (
            <section className="index">
              <div><LottiesC animationData ={lotties 1}  /> </div>
               <div><LottiesC  animationData ={lotties 2} /> </div>
              <div><LottiesC animationData ={lotties 3}  /> </div>
            </section>
          )
        }

        export default index

  ask by tedajo philippe translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...