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

🐛 自定义数据单元格 , 使用 handleRestOptions 存储 restOptions, 但在 handleHover (handleSelect等事件)中无法拿到值 #2462

Closed
1 of 5 tasks
xulingling0 opened this issue Dec 8, 2023 · 1 comment

Comments

@xulingling0
Copy link

🏷 Version

Package Version
@antv/s2 1.53.0
@antv/s2-react 1.45.0
@antv/s2-vue

Sheet Type

  • PivotSheet
  • TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

自定义数据单元格 , 使用 handleRestOptions 存储 restOptions, 但在 handleHover 中无法拿到值

⌨️ Code Snapshots

class CustomDataCell extends DataCell {

  restOptions = {};

 handleRestOptions(options) {
   this.restOptions = { ...options };
  // 这里拿到了 {interaction: hoverEffect: "cross"}
  console.log("handleRestOptions", this.restOptions);
}

 handleHover(cells) {
  // 期望:这里拿到的值应该和handleRestOptions打印的值一样
 // 实际:这里拿到的值是 {}
  console.log("handleHover", this.restOptions);
  super.handleHover(cells);
}

}

 const s2Options = {
  dataCell: (viewMeta) => {
      return new CustomDataCell(viewMeta, viewMeta?.spreadsheet, {
        interaction: { hoverEffect: "cross" },
      });
    },
 }

🔗 Reproduce Link

https://codesandbox.io/p/sandbox/romantic-wood-p7v842?file=%2Findex.ts%3A25%2C21

🤔 Steps to Reproduce

😊 Expected Behavior

😅 Current Behavior

💻 System information

Environment Info
System
Browser
@lijinke666
Copy link
Member

lijinke666 commented Dec 11, 2023

这样修改即可, 这个和 babel 或者你的其他打包工具编译有关系, 如果是 restOptions = {} 则会最后进行 constructor, 所以你的 restOptions 最后都会变成 {}, 你感兴趣的话可以对比下两者的编译产物的差异

class CustomDataCell extends DataCell {
-  restOptions = {};
+  restOptions

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

2 participants