react-踩坑记录——swiper报错!
已经在html文件中使用过,正确无误;但做成组件后(各种依赖文件引入路径确认无误)报错。
在只引入swiper.css时未报错,引入swiper.js文件后报错,如下:
错误原因,不详。
解决措施,不引入swiper.js,而是直接npm install swiper,在文件头部导入,如⬇️:
import React, { Component } from 'react'; import logo from './logo.svg'; import '../src/css/reset.css'; import '../src/css/swiper.css'; import '../src/css/slider.css'; import Swiper from 'swiper';class Slider extends Component {constructor(){super();this.state = {};}componentDidMount(){var swiper = new Swiper('.swiper-container', {pagination: '.swiper-pagination',nextButton: '.swiper-button-next',prevButton: '.swiper-button-prev',paginationClickable: true,spaceBetween: 30,centeredSlides: true,autoplay: 2500,autoplayDisableOnInteraction: false});}render(){return <div className="swiper-container"><div className="swiper-wrapper"><div className="swiper-slide">Slide 1</div><div className="swiper-slide">Slide 2</div><div className="swiper-slide">Slide 3</div><div className="swiper-slide">Slide 4</div></div><div className="swiper-pagination"></div><div className="swiper-button-next"></div><div className="swiper-button-prev"></div></div> } }class App extends Component {render(){return <div><Slider></Slider></div> } }export default App;
这时又出现了新问题,写在html 文件中预览时还能自动轮播的图片,拆成组件后只能手划动轮播。。。待解
转载于:https://www.cnblogs.com/LLLLily/p/7528147.html
react-踩坑记录——swiper报错!相关推荐
- 利用convert【ImageMagick】把pdf批量转换为图片踩坑(gs报错和清晰度问题)
利用convert[ImageMagick]把pdf批量转换为图片踩坑 前言 坑1 gs报错 解决方案: 坑2 导出的文件太模糊 解决方案 参数介绍: 总结 最后附上完整的命令 前言 最近做一个pdf ...
- 踩坑:gitee报错fatal: Couldn‘t find remote ref master。
在通过vscode提交代码到远程仓库的时候,报了这个错:fatal: Couldn't find remote ref master. 然后,我在网上找了超级多方法,基本都是检查仓库配置,我贴一下,看 ...
- [前端踩坑]引入组件报错Already included file name ‘XXX‘ differs from file name ‘XXX‘ only in casing.
报错代码: import Search from './components/Search.vue' 修改方式:去掉后缀".vue"即可(原因不明)
- 【踩坑记录】mybatis-plus的insert方法,默认会生成一个uuid作为主键,导致类型不一致,存入数据库报错
[踩坑记录]mybatis-plus的insert方法,默认会生成一个uuid作为主键,导致类型不一致,存入数据库报错 报错记录 解决方案 推荐方案 使用uuid作为主键,修改id的类型为bigint ...
- mysql 结束符报错_【踩坑记录】MySQL 实现自定义递归函数
因项目需要,需根据某个商品类别path,查询该类别下的所有子类别 表 goods-categories(path,parent_id,id) 该处使用的表为临时创建的表 t1(id,parent_i ...
- 【学习react中遇到的坑:内存泄漏报错】
学习react中遇到的坑:内存泄漏报错 对就是这个错误 Can't perform a React state update on an unmounted component. This is a ...
- uc浏览器请求被拦截报跨域踩坑记录
记录下开发时uc浏览器请求被拦截时遇到的问题 请求在uc浏览器出现跨域问题 app使用uniapp开发,使用plus.runtime.launchApplication来打开并跳转指定页面,并在Xco ...
- 为Jupyter notebook配置R kernel过程及踩坑记录
为Jupyter notebook配置R kernel过程及踩坑记录 注意:本文为作者安装过程及折腾的过程,内容比较冗杂,如果读者想直接创建一个属于自己的子环境则参考: 如下文章: anaconda下 ...
- Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子
Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子 目录 Python打包工具Pyintealler打包py文件为windows exe文件过程 ...
- osx php7 imagick,[PHP] MacOS 自带php环境安装imagick扩展踩坑记录 | 码农部落
前言 最近学习yii2,在搭建环境后,发现在访问contact页面时报错,如下: "Either GD PHP extension with FreeType support or Imag ...
最新文章
- Linux学习 - 目录的权限操作
- let 和 var 区别
- mysql2014授权设置_SQLServer2014许可证(六)虚拟化中的授权
- [LeetCode]#13 3sum
- 在 KubeSphere 中部署 Harbor
- c51单片机有几个终端语言,吃过大亏,才知道要从51单片机入手
- CentOS 7添加开机启动服务脚本
- nginx防火墙在哪设置_Nginx 基本使用介绍
- AS3显示当前帧速率的类:FrameRater Class
- 数据结构笔记(三十)-- 查找的基本概念和相关的顺序查找
- 面试时,如何巧妙回答跳槽问题
- 项管:配置管理、变更管理、文档管理、知识管理及其他
- carbon----代码美化工具
- iOS——Segue的使用
- Hugging Face:成为机器学习界的“GitHub”
- 腾讯云重装和还原操作系统
- HSC-1th 2022 48h大赛 write-up
- dhcp设置(Padavan dhcp设置)
- SRS低延时配置分析
- 计算机一级如何启动ie浏览器,ie,详细教您怎么解决ie浏览器打不开的问题
热门文章
- 电脑硬盘右击计算机就卡死,Win10电脑使用过程中莫名其妙卡死的的三种解决方法...
- 永磁同步电机转子磁链_永磁同步电机转子初始位置检测、增量式光电编码器对位调零思路解析...
- “/etc/profile“ 无法保存 E212: Can‘t open file for writing
- kubernetes service是什么
- MATLAB入门教程之MATLAB的基本知识
- 数据结构和算法——堆排序
- 基于springboot+vue的(高考)志愿录取系统(前后端分离)
- php 中function_PHP中的function函数详解
- MAC中JAVA安装和环境变量设置,java 11
- 6)Thymelead th:with 局部变量 与 属性优先级 和 Thymeleaf 注释