问题
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