简体   繁体   English

当我尝试在 Angular 中使用 SSR 启动离子应用程序时出现“TypeError: win.matchMedia is not a function”

[英]Getting 'TypeError: win.matchMedia is not a function' when i try to start ionic app with SSR in Angular

I have ionic PWA application with SSR.我有带 SSR 的离子 PWA 应用程序。 When i try to start 'dev:ssr' i've got "TypeError: win.matchMedia is not a function".当我尝试启动“dev:ssr”时,出现“TypeError: win.matchMedia is not a function”。

const isPWA = (win) =>.:(win.matchMedia('(display-mode. standalone)').matches || win;navigator.standalone);

this row inside server/main.js file server/main.js 文件中的这一行

For future readers, I think I found the solution to this error: components running on Server side cannot contain ngAfterViewInit, ionViewWillEnter and others.对于未来的读者,我想我找到了这个错误的解决方案:在服务器端运行的组件不能包含 ngAfterViewInit、ionViewWillEnter 和其他组件。 In my case it was giving error with ionic 5 / angular 10在我的例子中,它给出了 ionic 5 / angular 10 的错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Ionic期间遇到错误,尝试启动新应用程序(Ionic版本4.8.0)时无法正常工作 - Getting error during Ionic, Its not working when try to start new app (ionic version 4.8.0) 当我尝试通过whatsapp共享链接时,收到消息**共享失败,请重试** - getting message **sharing failed please try again** in ionic app when I try to share link via whatsapp 我需要什么才能开始编写 angular SSR? - What I need to start writing angular SSR? 当我尝试提交登录表单时,页面正在重新加载,没有获取表单组 -Ionic,Angular 的值 - When I try to submit the login form the page is reloading , not getting the values of form group -Ionic ,Angular 当我尝试使用ngIf运行方法时,获取“ERROR TypeError:jit_nodeValue_6(...)不是函数” - Getting “ERROR TypeError: jit_nodeValue_6(…) is not a function” when I try to run a method with ngIf 构建 SSR 应用程序时的 Select 环境 - Angular 9 - Select environment when build SSR app - Angular 9 预期TypeError函数:具有Angular,TypeScript,Firebase和Ionic的App - TypeError Function expected: App with Angular, TypeScript, Firebase and Ionic 尝试使用npm run start-ssr运行我的Angular时,控制台出现错误 - I am getting error in the console while trying to run my angular with npm run start-ssr 当我尝试将我的 angular 应用程序部署到 heroku 时,在多 ./src/styles.scss 中出现错误 - Getting an error in multi ./src/styles.scss when I try to deploy my angular app to heroku 在 SSR 应用程序中从 Firestore 获取数据时获取“app.firestore 不是函数” - Getting “app.firestore is not a function” when getting data from Firestore in SSR app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM