diff --git a/packages/taro-components/src/components/input/index.js b/packages/taro-components/src/components/input/index.js index 291eb338e48b..23c1b5b8196d 100644 --- a/packages/taro-components/src/components/input/index.js +++ b/packages/taro-components/src/components/input/index.js @@ -72,7 +72,7 @@ class Input extends Nerv.Component { value: { value } }) // 修复 IOS 光标跳转问题 - if (inputType !== 'number') { + if (!['number', 'file'].includes(inputType)) { const pos = e.target.selectionEnd setTimeout( () => { diff --git a/packages/taro-mobx-common/src/createProvider.js b/packages/taro-mobx-common/src/createProvider.js deleted file mode 100755 index e371c39916b3..000000000000 --- a/packages/taro-mobx-common/src/createProvider.js +++ /dev/null @@ -1,14 +0,0 @@ -import { setStore } from './store' - -export function createProvider (Component, Children) { - return class Provider extends Component { - constructor (props) { - super(props) - setStore(props.store) - } - - render () { - return Children.only(this.props.children) - } - } -} diff --git a/packages/taro-mobx-common/src/index.js b/packages/taro-mobx-common/src/index.js index f8ca3eb56bcf..a846660d6bd6 100755 --- a/packages/taro-mobx-common/src/index.js +++ b/packages/taro-mobx-common/src/index.js @@ -1,4 +1,3 @@ export { observer } from './observer' - export { inject } from './inject' -export { createProvider } from './createProvider' +export { setStore } from './store' diff --git a/packages/taro-mobx-h5/Provider.js b/packages/taro-mobx-h5/Provider.js new file mode 100755 index 000000000000..1b9193428425 --- /dev/null +++ b/packages/taro-mobx-h5/Provider.js @@ -0,0 +1,14 @@ +import { Children } from 'nervjs' +import { Component } from '@tarojs/taro-h5' +import { setStore } from '@tarojs/mobx-common' + +export default class Provider extends Component { + constructor (props) { + super(props) + setStore(props.store) + } + + render () { + return Children.only(this.props.children) + } +} diff --git a/packages/taro-mobx-h5/index.js b/packages/taro-mobx-h5/index.js index 4796e8877b70..7bc8ddae5071 100644 --- a/packages/taro-mobx-h5/index.js +++ b/packages/taro-mobx-h5/index.js @@ -1,11 +1,11 @@ import { Component } from '@tarojs/taro-h5' -import { createElement, Children } from 'nervjs' -import { createProvider, inject as originInject } from '@tarojs/mobx-common' +import { createElement } from 'nervjs' +import { inject as originInject } from '@tarojs/mobx-common' export function inject () { return originInject(...arguments, { Component, createElement }) } -export const Provider = createProvider(Component, Children) - export { observer } from '@tarojs/mobx-common' + +export { default as Provider } from './Provider' diff --git a/packages/taro-mobx-rn/Provider.js b/packages/taro-mobx-rn/Provider.js new file mode 100755 index 000000000000..155ee0763c08 --- /dev/null +++ b/packages/taro-mobx-rn/Provider.js @@ -0,0 +1,14 @@ +import { Children } from 'react' +import { Component } from '@tarojs/taro-rn' +import { setStore } from '@tarojs/mobx-common' + +export default class Provider extends Component { + constructor (props) { + super(props) + setStore(props.store) + } + + render () { + return Children.only(this.props.children) + } +} diff --git a/packages/taro-mobx-rn/index.js b/packages/taro-mobx-rn/index.js index 3134068e7470..2e3d3c8f06f1 100644 --- a/packages/taro-mobx-rn/index.js +++ b/packages/taro-mobx-rn/index.js @@ -1,11 +1,11 @@ import { Component } from '@tarojs/taro-rn' -import { Children, createElement } from 'react' -import { createProvider, inject as originInject } from '@tarojs/mobx-common' +import { createElement } from 'react' +import { inject as originInject } from '@tarojs/mobx-common' export function inject () { return originInject(...arguments, { Component, createElement }) } -export const Provider = createProvider(Component, Children) - export { observer } from '@tarojs/mobx-common' + +export { default as Provider } from './Provider' diff --git a/packages/taro-transformer-wx/src/class.ts b/packages/taro-transformer-wx/src/class.ts index 4bf0339b69b0..e3798ede781a 100644 --- a/packages/taro-transformer-wx/src/class.ts +++ b/packages/taro-transformer-wx/src/class.ts @@ -654,8 +654,6 @@ class Transformer { this.componentProperies, this.loopRefs ).outputTemplate - } else { - throw codeFrameError(this.classPath.node.loc, '没有定义 render 方法') } } diff --git a/packages/taro-transformer-wx/src/index.ts b/packages/taro-transformer-wx/src/index.ts index 688bc3126f71..7d130c335afa 100644 --- a/packages/taro-transformer-wx/src/index.ts +++ b/packages/taro-transformer-wx/src/index.ts @@ -5,7 +5,7 @@ import { prettyPrint } from 'html' import { transform as parse } from 'babel-core' import * as ts from 'typescript' import { Transformer } from './class' -import { setting, findFirstIdentifierFromMemberExpression, isContainJSXElement, codeFrameError, isArrayMapCallExpression } from './utils' +import { setting, findFirstIdentifierFromMemberExpression, isContainJSXElement, codeFrameError, isArrayMapCallExpression, pathResolver } from './utils' import * as t from 'babel-types' import { DEFAULT_Component_SET, INTERNAL_SAFE_GET, TARO_PACKAGE_NAME, REDUX_PACKAGE_NAME, MOBX_PACKAGE_NAME, IMAGE_COMPONENTS, INTERNAL_INLINE_STYLE, THIRD_PARTY_COMPONENTS, INTERNAL_GET_ORIGNAL, setLoopOriginal, GEL_ELEMENT_BY_ID } from './constant' import { Adapters, setAdapter, Adapter } from './adapter' @@ -241,7 +241,7 @@ export default function transform (options: Options): TransformResult { if (bindingPath.isImportDeclaration()) { const source = bindingPath.node.source try { - const p = fs.existsSync(source.value + '.js') ? source.value + '.js' : source.value + '.tsx' + const p = pathResolver(source.value, options.sourcePath) + (options.isTyped ? '.js' : '.js') const code = fs.readFileSync(p, 'utf8') componentProperies = transform({ isRoot: false,