diff --git a/packages/taro-cli/src/rn/styleProcess.ts b/packages/taro-cli/src/rn/styleProcess.ts index f00dd727889f..7b2261500ed5 100644 --- a/packages/taro-cli/src/rn/styleProcess.ts +++ b/packages/taro-cli/src/rn/styleProcess.ts @@ -5,10 +5,10 @@ import chalk from 'chalk' import * as pxtransform from 'postcss-pxtransform' import transformCSS from 'taro-css-to-react-native' -import {StyleSheetValidation} from './StyleSheet/index' +import { StyleSheetValidation } from './StyleSheet/index' import * as Util from '../util' import * as npmProcess from '../util/npm' -import {FILE_PROCESSOR_MAP, processTypeEnum} from '../util/constants' +import { FILE_PROCESSOR_MAP, processTypeEnum } from '../util/constants' import * as stylelintConfig from '../config/rn-stylelint.json' @@ -30,7 +30,6 @@ export default StyleSheet.create(${css}) `) } - /** * @description 读取 css/scss/less 文件,预处理后,返回 css string * @param {string} filePath @@ -38,7 +37,7 @@ export default StyleSheet.create(${css}) * @param {string} appPath * @returns {*} */ -function loadStyle({filePath, pluginsConfig}, appPath) { +function loadStyle ({filePath, pluginsConfig}, appPath) { const fileExt = path.extname(filePath) const pluginName = FILE_PROCESSOR_MAP[fileExt] if (pluginName) { @@ -73,7 +72,7 @@ function loadStyle({filePath, pluginsConfig}, appPath) { * @param {object} projectConfig * @returns {Function | any} */ -function postCSS({css, filePath, projectConfig}) { +function postCSS ({css, filePath, projectConfig}) { const pxTransformConfig = { designWidth: projectConfig.designWidth || 750 } @@ -102,7 +101,7 @@ function postCSS({css, filePath, projectConfig}) { }) } -function getStyleObject({css, filePath}) { +function getStyleObject ({css, filePath}) { let styleObject = {} try { styleObject = transformCSS(css) @@ -113,18 +112,21 @@ function getStyleObject({css, filePath}) { return styleObject } -function validateStyle({styleObject, filePath}) { +function validateStyle ({styleObject, filePath}) { for (const name in styleObject) { try { StyleSheetValidation.validateStyle(name, styleObject) } catch (err) { Util.printLog(processTypeEnum.WARNING, '样式不支持', filePath) - console.log(chalk.red(err.message)) + // 先忽略掉 fontSize 的报错 + if (err.message.indexOf(`"fontSize": "scalePx2dp`) === -1) { + console.log(chalk.red(err.message)) + } } } } -function writeStyleFile({css, tempFilePath}) { +function writeStyleFile ({css, tempFilePath}) { const fileContent = getWrapedCSS(css.replace(/"(scalePx2dp\(.*?\))"/g, '$1')) fs.ensureDirSync(path.dirname(tempFilePath)) fs.writeFileSync(tempFilePath, fileContent) diff --git a/packages/taro-rn/src/api/interface/showModal.js b/packages/taro-rn/src/api/interface/showModal.js index 11274ece9893..e0f968298d71 100644 --- a/packages/taro-rn/src/api/interface/showModal.js +++ b/packages/taro-rn/src/api/interface/showModal.js @@ -1,3 +1,4 @@ +import React from 'react' import { Text } from 'react-native' import RootSiblings from 'react-native-root-siblings' import Dialog from '../Dialog'