ScrollComponents FAQ
Question 1: When creating a view manager, how to pass external variables and update view properties through these variables?
View properties are set through the view manager's setViewStyle, which behaves like declarative syntax chaining calls and does not support passing state variables. You can use the @Watch decorator to listen for changes, and reset the properties via setViewStyle inside the listener function.
struct DemoPage {
@State @Watch('onChangeWidth') testWidth: string = '100%';
onChangeWidth() {
this.myManager.setViewStyle().width(this.testWidth);
}
// Set the property when it needs to be changed
buttonClick() {
this.testWidth = '50%';
}
}
Question 2: What is the difference between the preCreate and registerNodeItem APIs and when should they be called?
preCreate pre-creates nodes of the specified type and adds them to the recycle pool, while registerNodeItem is used to register a component template. preCreate must be called after registerNodeItem.
Question 3: Can the footer in waterFlowManger use a global builder function?
No. Currently the footer can only use a builder function inside the component.
Question 4: Can onItemDragStart in gridManager use a global builder function?
No. Currently the builder can only use a function inside the component.
Question 5: Does gridManager support setting the number of rows and columns occupied by child components?
No. Currently only an equal-ratio grid layout with the same item size is supported.
Question 6: Why do the header and footer in ListItemGroupManager not take effect?
The header currently supports the headerComponent property, which uses a global builder. The footer is written in the same way as the header.
Question 7: Why do the start and end builder properties of swipeAction not take effect when an item is swiped in a group layout?
swipeAction currently supports the builderComponent property, and GroupItemActionEnd can only be a global builder. The end and start are written in the same way.
Question 8: Does the third-party library currently support the v2 decorator?
No. The third-party library does not currently support the v2 decorator.