HarmonyOS 鸿蒙Next HMRouter 使用dialog动画配置colorOption提示Error message:Obj is not a Valid object
HarmonyOS 鸿蒙Next HMRouter 使用dialog动画配置colorOption提示Error message:Obj is not a Valid object
将HMRouterDemo里的隐私协议弹窗动画拿出来写到我的项目里就提示Error message:Obj is not a Valid object,找了好久没找到问题,哪位大佬帮我看看咋回事?谢谢
将HMRouterDemo里的隐私协议弹窗动画拿出来写到我的项目里就提示Error message:Obj is not a Valid object,找了好久没找到问题,哪位大佬帮我看看咋回事?谢谢
@Observed
export class ColorOption {
color: ResourceStr = 'rgba(0, 0, 0, 0)';
}
@HMAnimator({ animatorName: 'ZoomAnimator' })
export class ZoomAnimator implements IHMAnimator {
effect(enterHandle: HMAnimatorHandle, exitHandle: HMAnimatorHandle): void {
enterHandle.start((translateOption: TranslateOption, scaleOption: ScaleOption,
opacityOption: OpacityOption, colorOption: ColorOption) => {
scaleOption.x = 0.5;
scaleOption.y = 0.5;
colorOption.color = 'rgba(0, 0, 0, 0)';
}).finish((translateOption: TranslateOption, scaleOption: ScaleOption,
opacityOption: OpacityOption, colorOption: ColorOption) => {
scaleOption.x = 1;
scaleOption.y = 1;
colorOption.color = 'rgba(0, 0, 0, 0.3)';
});
exitHandle.start((translateOption: TranslateOption, scaleOption: ScaleOption,
opacityOption: OpacityOption, colorOption: ColorOption) => {
scaleOption.x = 1;
scaleOption.y = 1;
colorOption.color = 'rgba(0, 0, 0, 0.3)';
}).finish((translateOption: TranslateOption, scaleOption: ScaleOption,
opacityOption: OpacityOption, colorOption: ColorOption) => {
scaleOption.x = 0.5;
scaleOption.y = 0.5;
colorOption.color = 'rgba(0, 0, 0, 0)';
});
}
}
复制
@HMRouter({ pageUrl: RouterPath.PrivacyDialogPage, dialog: true, animator: 'ZoomAnimator' })
@Component
export struct PrivacyDialogPage {
scroller: Scroller = new Scroller();
build() {
Stack({ alignContent: Alignment.Center }) {
Column()
.width('100%')
.height('100%')
.backgroundColor('rgba(0,0,0,0.2)')
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
Column() {
Text('xx服务').fontSize(20)
.fontWeight(FontWeight.Bold)
.margin({ top: 20 })
.fontColor(Color.Black);
Text('业务说明')
.fontSize(16)
.margin({ top: 20 })
.width('90%')
.textAlign(TextAlign.Center)
.fontColor(Color.Black);
Scroll(this.scroller) {
Text() {
Span('xxxxxxxxxxf')
.fontColor(Color.Black);
Span('隐私协议')
.fontColor(Color.Blue)
.onClick(() => {
LogUtil.info('1234321')
HMRouterMgr.push({
pageUrl: 'https://privacy.consumer.huawei.com/legal/id/authentication-terms.htm?code=CN&language=zh-CN'
});
});
Span('。')
.fontColor(Color.Black);
Span('\n');
Span('点击同意。。。。。。')
.fontColor(Color.Black);
}
.fontSize(14)
.width('90%');
}
.scrollable(ScrollDirection.Vertical)
.margin({ top: 20 });
Row() {
Button('取消', { buttonStyle: ButtonStyleMode.TEXTUAL })
.onClick(() => {
HMRouterMgr.pop({ param: false });
AppUtil.exit()
})
.margin({
top: 20,
bottom: 20
})
.width('45%')
.fontColor(Color.Blue)
.fontWeight(FontWeight.Bold);
Divider()
.vertical(true)
.height(22)
.color(Color.Blue)
.opacity(0.3);
Button('同意', { buttonStyle: ButtonStyleMode.TEXTUAL })
.onClick(() => {
// 赋值同意了协议,进入到闪屏页面
PreferencesUtil.put(PreferencesKey.Privacy, true)
HMRouterMgr.pop({ param: true });
HMRouterMgr.replace({ pageUrl: 'SplashScreenPage', animator: false })
})
.margin({
top: 20,
bottom: 20
})
.width('45%')
.fontColor(Color.Blue)
.fontWeight(FontWeight.Bold);
};
}
.backgroundColor(Color.White)
.borderRadius(40)
.width('90%');
};
}
}
更多关于HarmonyOS 鸿蒙Next HMRouter 使用dialog动画配置colorOption提示Error message:Obj is not a Valid object的实战教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS 鸿蒙Next HMRouter 使用dialog动画配置colorOption提示Error message:Obj is not a Valid object的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
您好,已将demo上传至gitee,辛苦帮忙看下,谢谢 https://gitee.com/henson_zhang/hmrouter-test-demo
{ “scanDir”: [ “src/main/ets/components”, “src/main/ets/interceptors”, “src/main/ets/views”, “src/main/ets/lifecycle”, “src/main/ets/pages”, “src/main/ets/constants” ], “saveGeneratedFile”: false, “autoObfuscation”: false }
是这个吧,我没配置模板
HarmonyOS 鸿蒙Next HMRouter 在使用dialog动画配置colorOption时提示“Obj is not a Valid object”错误,通常是由于配置对象未正确初始化或传递。具体解决方法如下:
-
检查对象初始化:确保在使用colorOption之前,相关对象已被正确创建和初始化。对于dialog动画配置,需确保动画对象、dialog对象以及所有相关属性均已完成初始化。
-
检查属性传递:在配置colorOption时,检查是否将所有必要的参数正确传递给动画配置方法。确保没有遗漏或错误地传递参数。
-
检查API文档:参考HarmonyOS的官方API文档,确认colorOption的正确使用方法和参数要求。确保遵循文档中的指导进行配置。
-
代码审查:仔细检查代码,查找可能的逻辑错误或拼写错误,这些错误可能导致对象无法正确识别。
-
环境兼容性:确保开发环境(包括SDK版本和工具链)与HarmonyOS版本兼容。
如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html。