【发布时间】:2020-08-24 23:58:39
【问题描述】:
我想制作一个能够在 ionic App 中复制的文本。我试过这个How to allow copy and paste from an ionic webview? 解决方案。但这对我不起作用。请给我一个解决方案的建议。
【问题讨论】:
标签: ios iphone ionic-framework
我想制作一个能够在 ionic App 中复制的文本。我试过这个How to allow copy and paste from an ionic webview? 解决方案。但这对我不起作用。请给我一个解决方案的建议。
【问题讨论】:
标签: ios iphone ionic-framework
在 .css 文件中尝试以下代码。
.selectable {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
【讨论】:
尝试应用这些样式。
在您的 CSS 文件中:
ion-content{
overflow-scroll: true;
}
.scroll-content {
-webkit-user-select: auto !important;
-moz-user-select: auto !important;
-ms-user-select: auto !important;
user-select: auto !important;}
.selectable {
-webkit-user-select: auto;
}
在您的控制器中
stop_browser_behavior: false
self.touchStart = function(e) {
self.startCoordinates = getPointerCoordinates(e);
if ( ionic.tap.ignoreScrollStart(e) ) {
return;
}
if( ionic.tap.containsOrIsTextInput(e.target) ) {
// do not start if the target is a text input
// if there is a touchmove on this input, then we can start the scroll
self.__hasStarted = false;
return;
}
self.__isSelectable = true;
self.__enableScrollY = true;
self.__hasStarted = true;
self.doTouchStart(e.touches, e.timeStamp);
// e.preventDefault();
};
然后在您的 HTML 中:
<div class='selectable'>
This text should be selectable
</div>
【讨论】: