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

PickerViewColumn 使用提示路径错误 #562

Closed
ghost opened this issue Sep 2, 2018 · 3 comments
Closed

PickerViewColumn 使用提示路径错误 #562

ghost opened this issue Sep 2, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 2, 2018

问题描述
引入PickerView,PickerViewColumn同时使用会出现这个问题
copy 官网示例代码也出现这个问题~

复现步骤
具体看taro 示例代码

期望行为

报错信息

错误  组件错误  组件PickerViewColumn路径错误,请检查!(可能原因是导出的组件名不正确)
错误  页面编译  页面/Users/leon/Desktop/weapp2/src/pages/index/index编译失败!
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.relative (path.js:1173:5)
    at pageDepComponents.forEach.depComponent (/Users/leon/Desktop/weapp2/node_modules/_@[email protected]@@tarojs/cli/src/weapp.js:1197:64)
    at Array.forEach (<anonymous>)
    at componentMap.forEach.component (/Users/leon/Desktop/weapp2/node_modules/_@[email protected]@@tarojs/cli/src/weapp.js:1191:31)
    at Array.forEach (<anonymous>)
    at realComponentsPathList.forEach.component (/Users/leon/Desktop/weapp2/node_modules/_@[email protected]@@tarojs/cli/src/weapp.js:1190:24)
    at Array.forEach (<anonymous>)
    at buildSinglePage (/Users/leon/Desktop/weapp2/node_modules/_@[email protected]@@tarojs/cli/src/weapp.js:1187:30)
    at process._tickCallback (internal/process/next_tick.js:178:7)

系统信息

  • 操作系统: [macos]
  • Taro 版本 [1.0.0-beta.22]
  • Node.js 版本 [10]

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@luckyadam
Copy link
Member

贴一下文件的代码

@ghost
Copy link
Author

ghost commented Sep 2, 2018

@luckyadam

import Taro, { Component } from '@tarojs/taro'
import { View, PickerView, PickerViewColumn } from '@tarojs/components'

export default class Picks extends Component {

  constructor() {
    super(...arguments)
    const date = new Date()
    const years = []
    const months = []
    const days = []
    for (let i = 1990; i <= date.getFullYear(); i++) {
      years.push(i)
    }
    for (let i = 1; i <= 12; i++) {
      months.push(i)
    }
    for (let i = 1; i <= 31; i++) {
      days.push(i)
    }
    this.state = {
      years: years,
      year: date.getFullYear(),
      months: months,
      month: 2,
      days: days,
      day: 2,
      value: [9999, 1, 1],
    }
  }

  onChange = e => {
    const val = e.detail.value
    this.setState({
      year: this.state.years[val[0]],
      month: this.state.months[val[1]],
      day: this.state.days[val[2]],
      value: val
    })
  }

  render() {
    return (
      <View>
        <View>{this.state.year}{this.state.month}{this.state.day}</View>
        <PickerView indicatorStyle="height: 50px;" style="width: 100%; height: 300px;" value={this.state.value} onChange={this.onChange}>
          <PickerViewColumn>
            {this.state.years.map(item => {
              return (
                <View>{item}</View>
              );
            })}
          </PickerViewColumn>
          <PickerViewColumn>
            {this.state.months.map(item => {
              return (
                <View>{item}</View>
              );
            })}
          </PickerViewColumn>
          <PickerViewColumn>
            {this.state.days.map(item => {
              return (
                <View>{item}</View>
              );
            })}
          </PickerViewColumn>
        </PickerView>
      </View>
    )
  }
}

@luckyadam
Copy link
Member

已修复,下个版本发布~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant