From bebacd9a2da85ba47b031a914e00f6958930e9ad Mon Sep 17 00:00:00 2001 From: Pines-Cheng Date: Sun, 2 Jun 2019 16:54:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(rn):=20=E5=BF=BD=E7=95=A5=20scalePx2d=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=20Invalid=20prop=20`fontSize`=20of?= =?UTF-8?q?=20type=20`string`=20=E7=9A=84=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-cli/src/rn/styleProcess.ts | 20 ++++++++++--------- .../taro-rn/src/api/interface/showModal.js | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) 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'