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

SwiperAction 支持通过 slot 定制 Button #1121

Open
DiamondYuan opened this issue Mar 18, 2024 · 2 comments
Open

SwiperAction 支持通过 slot 定制 Button #1121

DiamondYuan opened this issue Mar 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@DiamondYuan
Copy link
Collaborator

DiamondYuan commented Mar 18, 2024

背景

目前的 SwipeAction 只支持通过 text 来定制文本

期望

希望可以自定义样式, 比如在文本下面多一个 icon

@DiamondYuan DiamondYuan added the enhancement New feature or request label Mar 18, 2024
@DiamondYuan
Copy link
Collaborator Author

思路 1 , 使用 slot-scope + named slot

<slot name='button'. position='left/right' index='index' text="getText()" item="item">

思路 2 , 用户自定义 slot 的名字

[{
slotName: 'button-one'
}]

<view slot="button-one" / >

思路 1 的缺点是微信不支持 named slot
思路 2 的缺点是不支持 confirmText

@DiamondYuan
Copy link
Collaborator Author

第二种思路的 slot 定义 与 消费


          {
            item.slotName  && item.confirm && <slot name="{{item.slotName}}-confirm">
            item.slotName && !item.confirm && <slot name="{{item.slotName}}">
            !item.slotName && <text>默认实现</text>
          }

          <block a:for="{{ rightBtns }}">
            <block a:if="{{ item.slotName }}">
              <view slot="{{item.slotName}}">
                {{item.text}}
              </view>
              <view slot="{{item.slotName}}-confirm">
               {{item.confirmText}}
              </view>
            </block>
          </block>

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

No branches or pull requests

1 participant