HarmonyOS Next开发过程中, 加载组件使用频率高, 但目前只能在Component类里面创建及调用, 代码冗余, 请问如何实现此组件抽取封装.
实现类似如下效果(以下是伪代码):
import YksLoadingView from '../components/YksLoadingView';
class LoadingUtils {
dialogController:CustomDialogController = new CustomDialogController({
builder: YksLoadingView(),
//是否允许点击遮障层退出。
autoCancel: false,
customStyle: true,
//弹窗在竖直方向上的对齐方式。
alignment:DialogAlignment.Center
});
showLoading() {
this.dialogController.open()
}
hideLoading() {
this.dialogController.close()
}
}
export default new LoadingUtils
参考以下demo: