Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taro next 支付宝 picker 组件 无法正常使用 #6804

Closed
psaren opened this issue Jun 28, 2020 · 7 comments
Closed

taro next 支付宝 picker 组件 无法正常使用 #6804

psaren opened this issue Jun 28, 2020 · 7 comments
Assignees
Labels
P-0 Critical, patch T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Milestone

Comments

@psaren
Copy link
Contributor

psaren commented Jun 28, 2020

问题描述

taro next 支付宝 picker 组件 无法正常使用

复现步骤

  1. taro init react-project
  2. 打开 pages/index/index.tsx
  3. 按照官网示例 picker, 添加代码
  4. 构建 npm run build:alipay
import React, { Component } from 'react'
import { View, Button, Text, Picker } from '@tarojs/components'
import { connect } from 'react-redux'

import { add, minus, asyncAdd } from '../../actions/counter'

import './index.scss'
type PageStateProps = {
  counter: {
    num: number
  }
}

type PageDispatchProps = {
  add: () => void
  dec: () => void
  asyncAdd: () => any
}

type PageOwnProps = {}

type PageState = {}

type IProps = PageStateProps & PageDispatchProps & PageOwnProps

interface Index {
  props: IProps;
}
class Index extends Component {
+  state = {
+    selector: ['美国', '中国', '巴西', '日本'],
+    selectorChecked: '美国',
+  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    console.log(this.props, nextProps)
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

+  onChange = e => {
+    this.setState({
+      selectorChecked: this.state.selector[e.detail.value]
+    })
+  }

  render () {
    return (
      <View className='index'>
        <Button className='add_btn' onClick={this.props.add}>+</Button>
        <Button className='dec_btn' onClick={this.props.dec}>-</Button>
        <Button className='dec_btn' onClick={this.props.asyncAdd}>async</Button>
        <View><Text>{this.props.counter.num}</Text></View>
        <View><Text>Hello, World</Text></View>
         <Text>地区选择器</Text>
+          <View>
+             <Picker mode='selector' range={this.state.selector} onChange={this.onChange}>
+               <View className='picker'>
+                当前选择:{this.state.selectorChecked}
+              </View>
+            </Picker>
+          </View>
      </View>
    )
  }
}

期望行为

Picker组件可正常使用

报错信息

没有报错信息,组件未能正常显示出来
微信小程序截图

支付宝小程序截图

系统信息

$ taro info
👽 Taro v3.0.0-rc.6

Taro CLI 3.0.0-rc.6 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.16.3 - D:\Program Files\nodejs\node.EXE
Yarn: E:\study\applets\next\taro-react>"D:\Program Files\nodejs\node.exe" "D:\Program Files\nodejs\node_modules\yarn\bin\yarn.js" -v
1.17.3 - D:\Program Files\nodejs\yarn.CMD
npm: 6.9.0 - D:\Program Files\nodejs\npm.CMD

在这个 #6594 issue 下会出现报错,现在已无报错,但仍然无法正常使用

@liujiayii
Copy link

我这里报警告,页面都出不来

@honlyHuang
Copy link
Contributor

honlyHuang commented Jun 29, 2020

@psaren 看见大佬在物料市场里提交了 taro-ui-vue ,求大佬微信号

@psaren
Copy link
Contributor Author

psaren commented Jun 29, 2020

@honlyHuang
Ace_Joseph

@wittech
Copy link

wittech commented Jul 3, 2020

Picker's child must be an element: <view>

@Junzibuzhengyibuqi
Copy link

还没解决吗 大佬们

@Chen-jj Chen-jj added T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x P-0 Critical, patch and removed 支付宝小程序 labels Jul 8, 2020
@taro-bot2 taro-bot2 bot added this to the 3.0.3 milestone Jul 8, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 8, 2020

支付宝 picker 的 children 只能为一个节点

目前 for 循环了一堆 view 所以跪了:

image

下个版本会给 picker 首先套一个 view 节点:

image

@lrfun
Copy link

lrfun commented Dec 2, 2020

taro 3.0.5 支付宝小程序 Picker无法正常使用组件,页面无法渲染

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-0 Critical, patch T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

7 participants