ionic 2: How to make text selectable?

2019-03-12 21:35发布

问题:

I want users to be able to select text content (in ionic 2) so that they can copy it and paste it elsewhere, but it seems that text selection has been disabled. Users can select text that is in an input or a textarea, but I want them to be able to select even regular content text. Is there a way to re-enable text selection?

回答1:

I added

body {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}

to the app.scss file

For individual items, since this is SCSS, you can also create a mix-in with those 4 css lines. Keep in mind Safari or other browsers may not respond well to just user-select.



回答2:

You need to add the following CSS to the HTML tag you want to be selectable

user-select: text;