亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

react 列表元素高度的獲取

react 列表元素高度的獲取

大話西游666 2019-05-19 13:57:33
在用react做一個h5的項目,遇到了一個坑,我在componentDidMount里面獲取不到正確的list元素高度,必須用到setTimeout才行,但是定時器也不靠譜啊, 有沒有更好的解決辦法呢webpack.config.js配置文件{          test: /\.(js|mjs)$/,          exclude: /@babel(?:\/|\\{1,2})runtime/,          loader: require.resolve('babel-loader'),          options: {            babelrc: false,            configFile: false,            compact: false,            presets: [              [                require.resolve('babel-preset-react-app/dependencies'),                { helpers: true },              ],            ],            cacheDirectory: true,            cacheCompression: isEnvProduction,                        // If an error happens in a package, it's possible to be            // because it was compiled. Thus, we don't want the browser            // debugger to show the original code. Instead, the code            // being evaluated would be much more helpful.            sourceMaps: false,          },        },        // "postcss" loader applies autoprefixer to our CSS.        // "css" loader resolves paths in CSS and adds assets as dependencies.        // "style" loader turns CSS into JS modules that inject <style> tags.        // In production, we use MiniCSSExtractPlugin to extract that CSS        // to a file, but in development "style" loader enables hot editing        // of CSS.        // By default we support CSS Modules with the extension .module.css        {          test: cssRegex,          exclude: cssModuleRegex,          use: getStyleLoaders({            importLoaders: 1,            sourceMap: isEnvProduction && shouldUseSourceMap,          }),          // Don't consider CSS imports dead code even if the          // containing package claims to have no side effects.          // Remove this when webpack adds a warning or an error for this.          // See https://github.com/webpack/webpack/issues/6571          sideEffects: true,        },
查看完整描述

3 回答

?
倚天杖

TA貢獻1828條經驗 獲得超3個贊

只在componentDidMount里獲取,組件更新的時候就獲取不到了,在componetUpdated里也獲取一下吧


查看完整回答
反對 回復 2019-05-19
?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

好奇問下這個 跟 webpack 有什么關系為什么還要貼這個配置


查看完整回答
反對 回復 2019-05-19
  • 3 回答
  • 0 關注
  • 2446 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號