如何使用离子视图在应用程序中显示console.log()

时间:2021-03-10 16:55:30

I'm busy testing my app on a browser and on my device with ionic view. I want to know if there is a way to have a browser type console.log displayed on my device with a label or something text based?

我正忙着在浏览器和我的设备上使用离子视图测试我的应用程序。我想知道是否有办法让我的设备上显示的浏览器类型console.log带有标签或基于文本的内容?

1 个解决方案

#1


13  

Well, sure you can make a <div> in your app at the bottom for example and log all the errors in there. So, everything you usually use with console.log() you would now append to this <div>.

好吧,确保你可以在底部的应用程序中创建一个

并记录那里的所有错误。因此,您通常使用console.log()的所有内容现在都会附加到此

However, I strongly suggest against that since it seems totally unpractical. What I would do in your case is run the application on your actual device with ionic run with these two options (as explained in the official documentation):

但是,我强烈反对这一点,因为它似乎完全不实用。在我的情况下,我会做的是使用离子运行在您的实际设备上运行这两个选项(如官方文档中所述):

With live reload enabled, an app's console logs can also be printed to the terminal/command prompt by including the --consolelogs or -c option. Additionally, the development server's request logs can be printed out using --serverlogs or -s options.

启用实时重新加载后,还可以通过包含--consolelogs或-c选项将应用程序的控制台日志打印到终端/命令提示符。此外,可以使用--serverlogs或-s选项打印开发服务器的请求日志。

#1


13  

Well, sure you can make a <div> in your app at the bottom for example and log all the errors in there. So, everything you usually use with console.log() you would now append to this <div>.

好吧,确保你可以在底部的应用程序中创建一个

并记录那里的所有错误。因此,您通常使用console.log()的所有内容现在都会附加到此

However, I strongly suggest against that since it seems totally unpractical. What I would do in your case is run the application on your actual device with ionic run with these two options (as explained in the official documentation):

但是,我强烈反对这一点,因为它似乎完全不实用。在我的情况下,我会做的是使用离子运行在您的实际设备上运行这两个选项(如官方文档中所述):

With live reload enabled, an app's console logs can also be printed to the terminal/command prompt by including the --consolelogs or -c option. Additionally, the development server's request logs can be printed out using --serverlogs or -s options.

启用实时重新加载后,还可以通过包含--consolelogs或-c选项将应用程序的控制台日志打印到终端/命令提示符。此外,可以使用--serverlogs或-s选项打印开发服务器的请求日志。