ionic 2: How to make text selectable?

前端 未结 5 1380
孤独总比滥情好
孤独总比滥情好 2020-12-14 08:14

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 se

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 08:58

    In Ionic 4 add

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

    **to the global.scss file. ** But if you want to copy/paste only a specific tag text, add something like this instead in your global.scss:

    .selectable {
    
        -webkit-user-select: text;
        
        -moz-user-select: text;
        
        -ms-user-select: text;
        
        user-select: text;
        
        }

    And then add class="selectable" property to the tag.

    Hope it helps

提交回复
热议问题