使用是官方的例程panel-universal(其他例程也有类似情况),在开发者工具中可以实现虚拟设备数据的正确下发,但真机调试的时候使用手机无法正确下发,但真实设备可以正常上传和下发数据。之前并没有出现过这种问题。
报错如下
Code: Select all
service.js:3 SyntaxError: Uncaught (in promise) [object Object] (at service.js:3:386161)
at new Be (service.js:3:386161)
at publishDps2 (publishDps.js:55:10)
at SmartDeviceModel.js:672:14
at SmartDeviceModel.__publishDps__ (logger.js:9:22)
at Object.set (SmartDeviceModel.js:294:29)
at onChange (index.tsx:43:29)
at onClick (index.tsx:26:26)
at onClick (Button.thing.js:29:57)
at handler (createCallbackProxy.js:66:18)
at Container.js:164:36
我对onclik和onchangge进行错误捕获,并没有捕获到错误信息。猜测是publishDps2这个函数出了问题。
Code: Select all
import React from 'react';
import { Button, Text, View } from '@ray-js/ray';
import Strings from '@/i18n';
import { getArray } from '@/utils/array';
import styles from './index.module.less';
export const EnumView: React.FC<ItemViewProps> = ({ item, dpValue, onChange }) => {
function getRange(){
var Range = [];
try{
Range = getArray(item?.property?.range as string[]);
}catch(error){
console.log("getRange",error);
}
return Range;
}
return (
<View className={styles.container}>
{getRange().map(rangeItem => (
<Button
key={rangeItem}
className={styles.item}
onClick={() => onChange(rangeItem)}
style={
rangeItem === dpValue
? {
backgroundColor: '#468AEE',
color: '#fff',
}
: {
backgroundColor: '#4689ee61',
color: '#fff',
}
}
>
<Text>{Strings.getDpLang(item.code, rangeItem)}</Text>
</Button>
))}
</View>
);
};