NervJS / taro-ui

一款基于 Taro 框架开发的多端 UI 组件库
https://taro-ui.taro.zone
MIT License
4.52k stars 756 forks source link

[3.0.0-3.0.0-alpha.3] 日历组件marks参数失效 #1125

Open NaccOll opened 4 years ago

NaccOll commented 4 years ago

问题描述

使用AtCalendar,并添加marks参数,希望进行标记,发生错误

复现步骤

<View><AtCalendar marks={[{ value: '2020/07/24' }]} /></View>

期望行为

希望对2020年7月24日进行标记

报错信息

Uncaught Error: Objects are not valid as a React child (found: object with keys {value}). If you meant to render a collection of children, use an array instead.
    in taro-text-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarList)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarList)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarList)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarList)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarList)
    in AtCalendarList (created by AtCalendarBody)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarBody)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarBody)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendarBody)
    in AtCalendarBody (created by AtCalendar)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by AtCalendar)
    in AtCalendar (created by Index)
    in taro-view-core (created by Index)
    in Index (created by ForwardRef)
    in ForwardRef (created by Index)
    in Index (created by Page)
    in div (created by Page)
    in Page (created by AppWrapper)
    in div (created by AppWrapper)
    in MobXProvider (created by App)
    in App (created by AppWrapper)
    in AppWrapper
    at throwOnInvalidObjectType (react-dom.development.js?61bb:13413)
    at reconcileChildFibers (react-dom.development.js?61bb:14313)
    at reconcileChildren (react-dom.development.js?61bb:16762)
    at updateHostComponent (react-dom.development.js?61bb:17302)
    at beginWork (react-dom.development.js?61bb:18627)
    at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:237)
    at invokeGuardedCallback (react-dom.development.js?61bb:292)
    at beginWork$1 (react-dom.development.js?61bb:23203)
    at performUnitOfWork (react-dom.development.js?61bb:22154)

系统信息

  Taro CLI 3.0.2 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.16.3 - C:\APP\nodejs\node.EXE
      npm: 6.14.4 - C:\APP\nodejs\npm.CMD

补充信息

https://github.com/NervJS/taro-ui/blob/next/packages/taro-ui/src/components/calendar/ui/date-list/index.tsx#L69

 <View className='flex__item-extra extra'>
              {item.marks && item.marks.length > 0 ? (
                <View className='extra-marks'>
                  {item.marks.map((mark, key) => (
                    <Text key={key} className='mark'>
                      {mark}
                    </Text>
                  ))}
                </View>
              ) : null}
            </View>

{mark}的值为{value:'2020/07/24},不是字符串,最终导致报错。

taro-ui-bot[bot] commented 4 years ago

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

changyuwu commented 4 years ago

请问taro3 + taro-ui-3.0.0.alpha3 按需加载起作用吗?为什么我只引入了一个taro-ui,run dev的时候包体积就直接2600k了,直接没办法预览了

vibin-lin commented 4 years ago

请问taro3 + taro-ui-3.0.0.alpha3 按需加载起作用吗?为什么我只引入了一个taro-ui,run dev的时候包体积就直接2600k了,直接没办法预览了

同样的问题,请问你找到解决的方法了吗?

changyuwu commented 4 years ago

请问taro3 + taro-ui-3.0.0.alpha3 按需加载起作用吗?为什么我只引入了一个taro-ui,run dev的时候包体积就直接2600k了,直接没办法预览了

同样的问题,请问你找到解决的方法了吗?

还没有。准备切回taro2了

mitayou commented 4 years ago

同样的问题,求解决

Kybs0 commented 4 years ago

同样的问题,求解决! 按文档上的marks={ [ { value: '2018/11/11' } ] }操作会报错,好像只能marks={['2020/7/25','2020/7/26']}这般设置 但是直接塞string[],并没有生效!生效的永远今日,是的不管设置啥日期,都是今日被标记。。。 image

NaccOll commented 4 years ago

@Kybs0 @mitayou 解决办法就是按我的补充信息自己去代码里面把taro-ui的mask去掉,然后从node_modules复制出来一份,webpack配个alias,把taro-ui指向你自己的那份。这样才能避免多人协作出现问题

thomasyxy commented 4 years ago

@NaccOll @Kybs0 @mitayou @changyuwu 我也遇到了这个问题,提了PR,不知道能不能解决你们的问题

Kybs0 commented 4 years ago

@NaccOll 是的,marks的map那段有问题。把代码复制下来,把那段mark删除,标记自定义随便改

beysong commented 3 years ago

这个按文档直接报错了,taro3.x

luvletterldl commented 3 years ago

各位是怎么解决这个问题的

StarksJohn commented 3 years ago

无解,弃坑

DevanXU commented 3 years ago

1年了这个问题还没解?

wanxiankai commented 3 years ago

请问这个问题解决了吗?我现在还有这个问题

Taro CLI 3.2.0 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.21.0 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.11 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.2.0 => 3.2.0 
      @tarojs/mini-runner: 3.2.0 => 3.2.0 
      @tarojs/react: 3.2.0 => 3.2.0 
      @tarojs/runtime: 3.2.0 => 3.2.0 
      @tarojs/taro: 3.2.0 => 3.2.0 
      @tarojs/webpack-runner: 3.2.0 => 3.2.0 
      babel-preset-taro: 3.2.0 => 3.2.0 
      eslint-config-taro: 3.2.0 => 3.2.0 
      react: ^17.0.0 => 17.0.2 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
    npmGlobalPackages:
      typescript: 3.5.3
mitayou commented 3 years ago

请问这个问题解决了吗?我现在还有这个问题

Taro CLI 3.2.0 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.21.0 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.11 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.2.0 => 3.2.0 
      @tarojs/mini-runner: 3.2.0 => 3.2.0 
      @tarojs/react: 3.2.0 => 3.2.0 
      @tarojs/runtime: 3.2.0 => 3.2.0 
      @tarojs/taro: 3.2.0 => 3.2.0 
      @tarojs/webpack-runner: 3.2.0 => 3.2.0 
      babel-preset-taro: 3.2.0 => 3.2.0 
      eslint-config-taro: 3.2.0 => 3.2.0 
      react: ^17.0.0 => 17.0.2 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
    npmGlobalPackages:
      typescript: 3.5.3

可以试试这个替代品 https://github.com/zkytech/taro-calendar-customizable

StarksJohn commented 3 years ago

请问这个问题解决了吗?我现在还有这个问题

Taro CLI 3.2.0 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.21.0 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.11 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.2.0 => 3.2.0 
      @tarojs/mini-runner: 3.2.0 => 3.2.0 
      @tarojs/react: 3.2.0 => 3.2.0 
      @tarojs/runtime: 3.2.0 => 3.2.0 
      @tarojs/taro: 3.2.0 => 3.2.0 
      @tarojs/webpack-runner: 3.2.0 => 3.2.0 
      babel-preset-taro: 3.2.0 => 3.2.0 
      eslint-config-taro: 3.2.0 => 3.2.0 
      react: ^17.0.0 => 17.0.2 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
    npmGlobalPackages:
      typescript: 3.5.3

可以试试这个替代品 https://github.com/zkytech/taro-calendar-customizable

可用,谢谢