Chrome app - how to reboot app?

半世苍凉 提交于 2019-12-24 10:46:10

问题


I am creating a Chrome app and I have made a Logout button in the app.

How can I restart/reset the app? (background.js / background page should be restarted)


回答1:


chrome.runtime API is your friend.

chrome.runtime.reload()

Reloads the app or extension.

Note that this will probably close all windows opened by the app.




回答2:


Thinking about the user experience I'm not sure if chrome.runtime.reload() is the best what you can do. It is far much better if you just create a some king of cleanup function which will release unused resources (user's data I mean). The same thing in the app window. If you are using some framework it is probably easy. But in the end reconsider cleaning up instead of rebooting the app.



来源:https://stackoverflow.com/questions/25730426/chrome-app-how-to-reboot-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!