NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.39k stars 4.78k forks source link

draggable-sheet #15429

Open cat-kun opened 6 months ago

cat-kun commented 6 months ago

这个特性解决了什么问题?

https://developers.weixin.qq.com/miniprogram/dev/component/draggable-sheet.html 半屏功能

这个 API 长什么样?

const DraggableSheet = 'draggable-sheet';

<DraggableSheet
    className='sheet'
    initial-child-size='0.5'
    min-child-size='0.2'
    max-child-size='0.8'
    snap
    snap-sizes={[0.4, 0.6]}
  >
    <ScrollView scrollY type='list' associative-container='draggable-sheet' bounces>
      半屏小程序内容
    </ScrollView>
  </DraggableSheet>

通过components 添加新组件、属性,页面无法渲染该组件

// config/index.ts
[
    '@tarojs/plugin-inject',
    {
      components: {
        // 为 ScrollView 组件新增了 'associative-container' 属性
        ScrollView: {
          'associative-container': '',
        },
        // 新增一个组件
        DraggableSheet: {
          'initial-child-size': '',
          'min-child-size': '',
          'max-child-size': '',
          'easing-function': '',
          snap: '',
          'snap-sizes': [],
          'worklet:onsizeupdate': '',
        },
      },
      // 新增的组件需要写映射
      componentsMap: {
        DraggableSheet: 'draggable-sheet',
      },
    },
  ],
isKiki commented 1 week ago

Taro3.6.11版本Vue3如何使用DraggableSheet功能 按照以上方法引入出现 Bad attr snap-sizes with message: unexpected token ).错误如何解决?