How to allow copy and paste from an ionic webview?

2019-04-06 17:59发布

问题:

I am using ionic and cordova to build a hybrid application.

However, I can't copy text from any of my webviews. From my Android phone or from the browser, copying text does not work. Selecting text and dragging the pointer does nothing.

This occurs for instance with the basic app generated by ionic start myApp tabs.

Simply put, how can I allow users to copy-paste?

回答1:

Make ion-content to overflow-scroll="true" and add a class to your copyable text

.selectable{
    -webkit-user-select: auto;
}

You cannot copy anything to clipboard from javascript for now programmatically. However it can be done from native side via plugin CordovaClipboard



回答2:

You can try with console.log() and copy/paste from the console.

Or if you need to copy from an emulator you can use Remote debugging