使用react-id-swiper的3D Coverflow效果未显示正确的样式

时间:2019-03-28 23:46:12

标签: reactjs 3d effect swiper coverflow

3D Coverflow效果无法正确显示预期的样式,带有react-id-swiper。

只需通过“ yarn add react-id-swiper”安装了react-id-swiper,通过“ yarn add swiper”安装了swip, 就像文档告诉我在npm网站“ https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.css”上所做的一样,在CSS文件中添加了“ @import https://www.npmjs.com/package/react-id-swiper”。

并在“ http://kidjp85.github.io/react-id-swiper/”上尝试了“ 3D Coverflow效果”。只是将带有标签的图像带入标签,但它仅显示照片的普通幻灯片。完全没有3D效果。

///这是我的React App.js文件。

import React, { Component } from 'react';
import Swiper from 'react-id-swiper';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    const params = {
      effect: 'coverflow',
      grabCursor: true,
      centeredSlides: true,
      slidesPerView: 'auto',
      coverflowEffect: {
        rotate: 50,
        stretch: 0,
        depth: 100,
        modifier: 1,
        slideShadows: true
      },
      pagination: {
        el: '.swiper-pagination'
      }
    };

    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>

        <Swiper {...params}>
            <img src="https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg" alt="image1"/>
            <img src="https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg" alt="image2"/>
            <img src="https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg" alt="image3"/>
            <img src="https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg" alt="image4"/>
            <img src="https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg" alt="image5"/>
        </Swiper> 
      </div>
    );
  }
}

export default App;

//这是我在同一文件夹中的App.css文件。

@import 'https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.css';

.App {
  text-align: center;
}

.App-logo {
  animation: App-logo-spin infinite 20s linear;
  height: 40vmin;
  pointer-events: none;
}

.App-header {
  background-color: #282c34;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(10px + 2vmin);
  color: white;
}

.App-link {
  color: #61dafb;
}

@keyframes App-logo-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

它必须显示照片的典型3D Coverflow效果,在此链接中:http://kidjp85.github.io/react-id-swiper/ 但是现在它只显示普通的照片幻灯片。原因可能是什么,我该怎么办?The result I get. just slides of pictures.

0 个答案:

没有答案