Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): fix webrender not show when length is 1 #4087

Merged
merged 7 commits into from
Oct 23, 2024
Next Next commit
feat(vue-next): fix beforeLoadStyle not work
  • Loading branch information
zealotchen0 committed Aug 23, 2024
commit e4045b49e4c6d4e8f6a7f49f9f1c7b07ff3a5c44
19 changes: 19 additions & 0 deletions examples/hippy-vue-next-demo/src/main-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ const app: HippyApp = createApp(App, {
* default is true, if set false, it will follow vue-loader compilerOptions whitespace setting
*/
trimWhitespace: true,
styleOptions: {
beforeLoadStyle: (decl) => {
let { value } = decl;
// 比如可以对 rem 单位进行处理
if (typeof value === 'string' && /rem$/.test(value)) {
// get the numeric value of rem

const { screen } = Native.Dimensions;
// 比如可以对 rem 单位进行处理
if (typeof value === 'string' && /rem$/.test(value)) {
const { width, height } = screen;
// 防止hippy 旋转后,宽度发生变化
const realWidth = width > height ? width : height;
value = Number(parseFloat(`${(realWidth * 100 * Number(value.replace('rem', ''))) / 844}`).toFixed(2));
}
}
return { ...decl, value };
},
},
});
// create router
const router = createRouter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function getCssMap(
* Here is a secret startup option: beforeStyleLoadHook.
* Usage for process the styles while styles loading.
*/
const cssRules = fromAstNodes(styleCssMap);
const cssRules = fromAstNodes(styleCssMap, beforeLoadStyle);
if (globalCssMap) {
globalCssMap.append(cssRules);
} else {
Expand Down
Loading