antd mobile(antd-Mobile走马灯Carousel遇到的坑)

2025-11-08 12:30:01 :0

antd mobile(antd-Mobile走马灯Carousel遇到的坑)

本篇文章给大家谈谈antd mobile,以及antd-Mobile走马灯Carousel遇到的坑对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录

antd-Mobile走马灯Carousel遇到的坑

问题:当Carousel数据通过接口获取时,自动切换效果就会无效,且首页展示的高度为默认的最小高度;只有手动切换一张之后,才能启动自动切换,且高度恢复为正常高度;
原因:

解决方法一:设置flag值,等数据加载完之后,重新render,此时再加载Carousel组件,就能正常启动了。这种方法的问题是,页面在重新加载时,会有2s左右的延时,性能很不好。
解决方法二: 加入componentDidUpdate函数

依然通过flag去控制是否自动切换,当接口请求结束flag设置为true,render结束后立即执行componentDidUpdate函数,此时数据已经加载完成,这时通过flag设置成自动切换,之所以取反,是因为flag一直为true就会死循环了。亲测如果没有componentDidUpdate函数,只通过componentDidMount函数以及display={flag}来控制,也是行不通的。
通过百度多种尝试后最后一个可行,但有些原理还不是特别清楚,欢迎指正。

antd-mobile的ListView组件踩坑

一、ListView容器不加固定高度就无法展示问题

如题,但有的情况下我们不好确定固定高度,这时可以加个useBodyScroll属性,使用html的body作为滚动容器,就不需要设置固定高度了。

二、加了useBodyScroll属性后不触发onScroll和onEndReached事件

在上面的基础上加了useBodyScroll属性后,发现onScroll和onEndReached事件不生效了,这是因为我在ListView外层有一个其他元素,导致onScroll事件失效了,解决办法是把外层元素去掉,如果想要外层元素,就不要加useBodyScroll属性了。

[BUG]react引入antd-mobile报错

Module not found: Error: Can’t resolve ’antd-mobile/es/config-provider’
报错原因:babel.config.js配置错误
解决方法如下:

antdmobile怎么下载旧版本

在浏览器搜索下载。
打开浏览器,在搜索框输入antdmobile旧版本,然后点击搜索,会出现很多下载文章,随便点击进入一个,点击下载就可以了。

二次封装antd-mobile组件库

项目使用了typescript + less + react + antd-mobile 开发。

开发过程中进行了三种方式的尝试:webpack+rollup+tsc
1.rm -rf dist && tsc -p tsconfig.json && lessc src/index.less ./dist/index.css
2.rm -rf dist && webpack --mode production
3.rollup -wc

tsc+less:
效果:打包ts,less需要手动整合,不能按需加载
webpack:
效果:打包ts,会把webpack的东西打包进项目里,打包时间长

rollup 效果最好,最简单

microbundle-crl 这是一个封装好的配置rollup打包组件库的插件
package.json 配置 "build": "microbundle-crl --no-compress --format modern" 打包成 es6

reactantd-mobile项目中如何实现css与less局部作用域化的功能


这篇文章给大家介绍的内容是关于react antd-mobile项目中如何实现 css 与 less 局部作用域化的功能,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
1、前言最近搭建的 react 项目想引入 less ,并实现样式局部作用域化,但是在网上找了很多方法试过了都不行,最后打到解决方法,在此记下这惨痛的历程。
2、create-react-appcreate-react-app 是业界最优秀的 React 相关应用开发工具之一,本文档就是以此工具来使用 antd-mobile 组件。
安装和初始化#$ npm install -g create-react-app
# 注意:工具会自动初始化一个脚手架并安装 React 项目的各种必要依赖,如果在过程中出现网络问题,请尝试配置代理或使用其他 npm registry。
$ create-react-app my-app
$ cd my-app
***隐藏网址***
3、修改 css 配置下面是修改文件 webpack.config.js。
module.exports = {
entry: __dirname + ’/index.js’,
output: {
publicPath: ’/’,
filename: ’./bundle.js’
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: ’babel’,
query: {
presets:
}
},
{
test: /\.css$/,
loader: "style-loader!css-loader?modules"
},
]
}
};上面代码中,关键的一行是style-loader!css-loader?modules,它在css-loader后面加了一个查询参数modules,表示打开 CSS Modules 功能。
4、 配置 less首先安装 less 和 less-loader
npm i --save-dev less less-loader然后在 webpack.config.dev 中配置 less :
//这里我开启自己编写的less文件的css modules功能 除了node_modules库中的less,
//也就是可以过滤掉antd库中的样式
{
test: /\.less$/,
exclude: ,
use: [
require.resolve(’style-loader’),
{
loader: require.resolve(’css-loader’),
options: {
modules: true,
localIndexName: ""
},
},
{
loader: require.resolve(’less-loader’), // compiles Less to CSS
},
],
},5、完整配置送上完整的 webpack.config.dev 配置:
’use strict’;
const autoprefixer = require(’autoprefixer’);
const path = require(’path’);
const webpack = require(’webpack’);
const HtmlWebpackPlugin = require(’html-webpack-plugin’);
const CaseSensitivePathsPlugin = require(’case-sensitive-paths-webpack-plugin’);
const InterpolateHtmlPlugin = require(’react-dev-utils/InterpolateHtmlPlugin’);
const WatchMissingNodeModulesPlugin = require(’react-dev-utils/WatchMissingNodeModulesPlugin’);
const eslintFormatter = require(’react-dev-utils/eslintFormatter’);
const ModuleScopePlugin = require(’react-dev-utils/ModuleScopePlugin’);
const getClientEnvironment = require(’./env’);
const paths = require(’./paths’);
// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
const publicPath = ’/’;
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
const publicUrl = ’’;
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
module.exports = {
// You may want ’eval’ instead if you prefer to see the compiled output in DevTools.
***隐藏网址***
devtool: ’cheap-module-source-map’,
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
entry: [
// We ship a few polyfills by default:
require.resolve(’./polyfills’),
// Include an alternative client for WebpackDevServer. A client’s job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve(’webpack-dev-server/client’) + ’?/’,
// require.resolve(’webpack/hot/dev-server’),
require.resolve(’react-dev-utils/webpackHotDevClient’),
// Finally, this is your app’s code:
paths.appIndexJs,
// We include the app code last so that if there is a runtime error during
// initialization, it doesn’t blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
],
output: {
// Add /* filename */ comments to generated require()s in the output.
pathinfo: true,
// This does not produce a real file. It’s just the virtual path that is
// served by WebpackDevServer in development. This is the JS bundle
// containing code from all our entry points, and the Webpack runtime.
filename: ’static/js/bundle.js’,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: ’static/js/.chunk.js’,
// This is the URL that app is served from. We use "/" in development.
publicPath: publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: info =》
path.resolve(info.absoluteResourcePath).replace(/\\/g, ’/’),
},
resolve: {
// This allows you to set a fallback for where Webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
// if there are any conflicts. This matches Node resolution mechanism.
***隐藏网址***
modules: .concat(
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
),
// These are the reasonable defaults supported by the Node ecosystem.
// We also include JSX as a common component filename extension to support
// some tools, although we do not recommend using it, see:
***隐藏网址***
// `web` extension prefixes have been added for better support
// for React Native Web.
extensions: ,
alias: {
// Support React Native Web
***隐藏网址***
’react-native’: ’react-native-web’,
},
plugins: [
// Prevents users from importing files from outside of src/ (or node_modules/).
// This often causes confusion because we only process files within src/ with babel.
// To fix this, we prevent you from importing files out of src/ -- if you’d like to,
// please link the files into your node_modules/ and let module-resolution kick in.
// Make sure your source files are compiled, as they will not be processed in any way.
new ModuleScopePlugin(paths.appSrc, ),
],
},
module: {
strictExportPresence: true,
rules: [
// TODO: Disable require.ensure as it’s not a standard language feature.
***隐藏网址***
// { parser: { requireEnsure: false } },
// First, run the linter.
// It’s important to do this before Babel processes the JS.
{
test: /\.(js|jsx|mjs)$/,
enforce: ’pre’,
use: [{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve(’eslint’),
},
loader: require.resolve(’eslint-loader’),
}, ],
include: paths.appSrc,
},
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// A missing `test` is equivalent to a match.
{
test: ,
loader: require.resolve(’url-loader’),
options: {
limit: 10000,
name: ’static/media/’,
},
},
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve(’babel-loader’),
options: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
},
},
{
test: /\.css$/,
loader: "style-loader!css-loader?modules"
},
//@Lynn 这里我开启自己编写的less文件的css modules功能 除了node_modules库中的less,
//也就是可以过滤掉antd库中的样式
{
test: /\.less$/,
exclude: ,
use: [
require.resolve(’style-loader’),
{
loader: require.resolve(’css-loader’),
options: {
modules: true,
localIndexName:""
},
},
{

以上就是我们为大家找到的有关“antd mobile(antd-Mobile走马灯Carousel遇到的坑)”的所有内容了,希望可以帮助到你。如果对我们网站的其他内容感兴趣请持续关注本站。

antd mobile(antd-Mobile走马灯Carousel遇到的坑)

本文编辑:admin

更多文章:


entertainment系列(全球一线游戏制作公司有哪些)

entertainment系列(全球一线游戏制作公司有哪些)

本篇文章给大家谈谈entertainment系列,以及全球一线游戏制作公司有哪些对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。本文目录全球一线游戏制作公司有哪些三星手机的型号各代表是什么手机FocusEntertainment的In

2025年9月21日 01:00

下拉框选择怎么设置多个内容(Excel数据有效性设置的下拉菜单内容有多个,但选择时只能单选,如何设置下拉菜单,可以在选择时多选)

下拉框选择怎么设置多个内容(Excel数据有效性设置的下拉菜单内容有多个,但选择时只能单选,如何设置下拉菜单,可以在选择时多选)

本篇文章给大家谈谈下拉框选择怎么设置多个内容,以及Excel数据有效性设置的下拉菜单内容有多个,但选择时只能单选,如何设置下拉菜单,可以在选择时多选对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有

2025年7月29日 03:15

uandroid免登录版(uandroid账号密码)

uandroid免登录版(uandroid账号密码)

这篇文章给大家聊聊关于uandroid免登录版,以及uandroid账号密码对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。本文目录uandroid账号密码uandroidtool免费账号uandroid刷机到super不成功uand

2026年8月9日 12:00

find命令排除目录(如何用find命令只查找到文件,但不包括目录)

find命令排除目录(如何用find命令只查找到文件,但不包括目录)

大家好,今天小编来为大家解答以下的问题,关于find命令排除目录,如何用find命令只查找到文件,但不包括目录这个很多人还不知道,现在让我们一起来看看吧!本文目录如何用find命令只查找到文件,但不包括目录find 命令的使用笔记grep命

2026年2月25日 16:15

坐卧铺换票卡是什么意思(火车上,卧铺的车票为什么要换牌有什么作用)

坐卧铺换票卡是什么意思(火车上,卧铺的车票为什么要换牌有什么作用)

各位老铁们,大家好,今天由我来为大家分享坐卧铺换票卡是什么意思,以及火车上,卧铺的车票为什么要换牌有什么作用的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!

2025年10月31日 08:45

switch官网是多少(switch官方价)

switch官网是多少(switch官方价)

本篇文章给大家谈谈switch官网是多少,以及switch官方价对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。本文目录switch官方价switc

2025年8月7日 04:15

microchip英文介绍(帮忙翻译,要求使用被动语态,谢谢啊)

microchip英文介绍(帮忙翻译,要求使用被动语态,谢谢啊)

大家好,今天小编来为大家解答以下的问题,关于microchip英文介绍,帮忙翻译,要求使用被动语态,谢谢啊这个很多人还不知道,现在让我们一起来看看吧!本文目录帮忙翻译,要求使用被动语态,谢谢啊单片机 芯片都有什么型号简要介绍一下 不会的不要

2026年9月3日 12:00

flash 官方网站(给几个FLASH的网站)

flash 官方网站(给几个FLASH的网站)

本篇文章给大家谈谈flash 官方网站,以及给几个FLASH的网站对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。本文目录给几个FLASH的网站adobe flash player for ie 10.1给个官方网址adobeflas

2025年12月27日 13:15

exhausting什么意思(exhaust是什么意思)

exhausting什么意思(exhaust是什么意思)

本篇文章给大家谈谈exhausting什么意思,以及exhaust是什么意思对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。本文目录exhaust是什么意思exhausted的 exhausting区别 拜托了,速速的exhaust英

2026年3月12日 01:45

怎么截取String数组?如何对于一个数组的截取操作

怎么截取String数组?如何对于一个数组的截取操作

各位老铁们,大家好,今天由我来为大家分享数组的截取,以及怎么截取String数组的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!本文目录怎么截取String

2026年9月14日 06:00

网页游戏小小忍者游戏单机版,有源代码的详细说下怎么弄(本人菜鸟)?求网页游戏《倾城》服务端和客户端源码

网页游戏小小忍者游戏单机版,有源代码的详细说下怎么弄(本人菜鸟)?求网页游戏《倾城》服务端和客户端源码

这篇文章给大家聊聊关于倾城源码,以及网页游戏小小忍者游戏单机版,有源代码的详细说下怎么弄(本人菜鸟)对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。本文目录网页游戏小小忍者游戏单机版,有源代码的详细说下怎么弄(本人菜鸟)求网页游戏《倾

2026年7月11日 08:45

微信怎么打开html文件(html网页怎么微信打开)

微信怎么打开html文件(html网页怎么微信打开)

本篇文章给大家谈谈微信怎么打开html文件,以及html网页怎么微信打开对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。本文目录html网页怎么微信

2026年9月3日 18:15

prize如何记忆(如何分辨prize和price)

prize如何记忆(如何分辨prize和price)

本篇文章给大家谈谈prize如何记忆,以及如何分辨prize和price对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。本文目录如何分辨prize和priceprize怎么读音发音“price”和“prize”傻傻分不清楚如何分辨pr

2026年3月3日 03:00

java颜色代码表(Cult3D 高级教程之改变材质颜色的java代码)

java颜色代码表(Cult3D 高级教程之改变材质颜色的java代码)

大家好,如果您还对java颜色代码表不太了解,没有关系,今天就由本站为大家分享java颜色代码表的知识,包括Cult3D 高级教程之改变材质颜色的java代码的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!本文目录Cult

2025年7月27日 00:00

C#如何将UTF8的编码转回汉字?各位大神这个编码怎么转换成汉字,必须

C#如何将UTF8的编码转回汉字?各位大神这个编码怎么转换成汉字,必须

大家好,编码转汉字相信很多的网友都不是很明白,包括C#如何将UTF8的编码转回汉字也是一样,不过没有关系,接下来就来为大家分享关于编码转汉字和C#如何将UTF8的编码转回汉字的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧

2025年7月30日 12:30

502 bad gateway nginx是什么意思(电脑出现502bad gateway怎么解决)

502 bad gateway nginx是什么意思(电脑出现502bad gateway怎么解决)

大家好,502 bad gateway nginx是什么意思相信很多的网友都不是很明白,包括电脑出现502bad gateway怎么解决也是一样,不过没有关系,接下来就来为大家分享关于502 bad gateway nginx是什么意思和电

2026年3月7日 02:30

搬瓦工如何制作网站(如何使用爬虫做一个网站)

搬瓦工如何制作网站(如何使用爬虫做一个网站)

各位老铁们好,相信很多人对搬瓦工如何制作网站都不是特别的了解,因此呢,今天就来为大家分享下关于搬瓦工如何制作网站以及如何使用爬虫做一个网站的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!本文目录如何使用爬虫做一个网站Wo

2026年9月18日 22:00

1688app(1688app什么时候出的)

1688app(1688app什么时候出的)

大家好,如果您还对1688app不太了解,没有关系,今天就由本站为大家分享1688app的知识,包括1688app什么时候出的的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!本文目录1688app什么时候出的小红书上说的1

2025年6月16日 10:00

outrageously中文(lovely和cute区别)

outrageously中文(lovely和cute区别)

这篇文章给大家聊聊关于outrageously中文,以及lovely和cute区别对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。本文目录lovely和cute区别lovely和cute的区别是什么rageous是啥意思lovely和

2026年8月4日 03:45

gridview更新编辑(C#后台动态生成的gridview怎么加入 编辑 更新 取消)

gridview更新编辑(C#后台动态生成的gridview怎么加入 编辑 更新 取消)

大家好,今天小编来为大家解答以下的问题,关于gridview更新编辑,C#后台动态生成的gridview怎么加入 编辑 更新 取消这个很多人还不知道,现在让我们一起来看看吧!本文目录C#后台动态生成的gridview怎么加入 编辑 更新 取

2026年5月30日 05:15

近期文章

本站热文

electronics软件(labcenter electronics是什么软件)
2025-05-22 23:45:02 浏览:134
博客是微博吗(博客是微博吗)
2025-05-22 22:45:01 浏览:111
diversity and distribution(悬赏英语短文)
2025-05-23 16:15:02 浏览:107
ios软件开发前景(iOS就业前景怎么样)
2025-05-22 23:00:01 浏览:102
next month(有The next month这个单词吗,和 next month有什么区别)
2025-05-23 02:30:01 浏览:102
patron(patron是什么意思)
2025-05-23 10:30:02 浏览:95
标签列表

热门搜索