当我尝试使用HTML5 Canvas drawImage并将页面从Canvas页面更改为另一个页面时,我在React中遇到此错误:
TypeError:无法在'CanvasRenderingContext2D'上执行'drawImage':提供的值不是'(CSSImageValue或HTMLImageElement或SVGImageElement或HTMLVideoElement或HTMLCanvasElement或ImageBitmap或OffscreenCanvas)'
这是错误https://www.useloom.com/share/3c233254114a45c2933068cc2324c579
在这种情况下怎么了? 谢谢!
答案 0 :(得分:0)
我找到了解决方案,有必要检查是否有图像,并在有图像的情况下调用drawImage()。这是我的代码
import org.apache.commons.beanutils.*;
import org.apache.commons.beanutils.converters.DateConverter;
import java.util.Date;
public class Main {
public static void main(String[] args) throws Exception {
DateConverter converter = new DateConverter();
converter.setPattern("yyyy-MM-dd");
ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean();
convertUtilsBean.register(converter, Date.class);
BeanUtilsBean beanUtilsBean = new BeanUtilsBean(convertUtilsBean, new PropertyUtilsBean());
UserDto dto = new UserDto("42", "2018-11-14");
System.out.println("dto.getUserId() = " + dto.getUserId());
System.out.println("dto.getDob() = " + dto.getDob());
UserModel model = new UserModel();
beanUtilsBean.copyProperties(model, dto);
System.out.println("model.getUserId() = " + model.getUserId());
System.out.println("model.getDob() = " + model.getDob());
}
}