获得容器标准 16:9 实际宽高
const getStandardRatio = (width, height, widthRatio = 16, heightRatio = 9) => {
// 实际宽高比
const computedRatio = width / height;
// 标准宽高比
const standardRatio = widthRatio / heightRatio;
// 以高为准
if (computedRatio >= standardRatio) {
const computedWidth = (height * widthRatio) / heightRatio;
return {
width: computedWidth,
height,
};
}
// 以宽为准
const computedHeight = (width * heightRatio) / widthRatio;
return {
width,
height: computedHeight,
};
};
以自己现在的努力程度,还没有资格和别人拼天赋

浙公网安备 33010602011771号