罗文
罗文
  • 发布:2019-01-23 12:11
  • 更新:2023-10-25 01:12
  • 阅读:3642

【报Bug】text组件并且selectable设置为true,在iPhone的Safari不可以选中其中的文字

分类:uni-app

详细问题描述(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
[内容]
text组件并且selectable设置为true,在iPhone的Safari不可以选中其中的文字

重现步骤
代码如下

[步骤]
uni-app编译成H5版并上传服务器

[结果]
text组件的内容不能选中

[期望]
text组件的内容可以选中

IDE运行环境说明
HBuilderX

[IDE版本号]
1.5.2

  1. [windows版本号]
    win10

App运行环境说明
iPhone的Safari

[手机型号]
iPhone 7 puls ios12.1

2019-01-23 12:11 负责人:无 分享
已邀请:
逆流而上11

逆流而上11

用user-select替换selectable

小四川6

小四川6

在text加上user-select="true"苹果手机就可以复制了:

<text selectable="true" user-select="true">苹果手机也可以复制</text>
Trust

Trust - 少说废话

text 只能嵌套 text 组件并且复制 text 组件内的文本。
另外提供一下 safari 以及 iOS 设备的版本信息,以便测试确认下浏览器的兼容性问题。

  • 罗文 (作者)

    text嵌套text,还是不能复制。

    2019-01-24 13:01

  • 罗文 (作者)

    我测试了一遍,麻烦再看一下最新我的评论。

    2019-01-26 01:17

罗文

罗文 (作者)

新代码如下

还是不能选中复制哦

ios版本12.0.1
safari版本不会看,就是系统自带的那个版本

  • Trust

    text 都加上这个属性,里面循环的那个加上。这个属性不会继承的。

    2019-01-24 13:38

罗文

罗文 (作者)

我在win10上开发,在iPhone7 plus iOS:12.0.1,safari版本查不到,局域网内测试。

这样写可以选中

以下两种都不能选中

  • 虫雪浓

    按你的方式测试了一下,是没问题的,你贴一下代码吧, 不要截图,整体代码贴一下,我用你的代码在测试一下 ,看看是不是哪里写的有问题

    2019-01-26 12:04

  • 罗文 (作者)

    <template>

    <view id="body" class="page">

    <view class="line">

    <view class="label">需要多少个名字?</view>

    <input adjust-position="true" placeholder-style="font-size:28upx;display: flex;align-items: center;color:#CCC" class="uni-input"

    name="n" placeholder="1-500个" v-model="n" type="number" />

    </view>

    <view style="width: 750upx;height: 80upx;justify-content: space-around;margin-top: 30upx;">

    <view class="save" @tap="submit()">

    确 定

    </view>

    </view>

    <view class="nameList">

    <!-- #ifndef H5 -->

    <view class="name" v-for="(v, m) in nl" :key="m" @tap="copy()">

    {{(m-0)+1}}{{v}}

    </view>

    <!-- #endif -->

    <!-- #ifdef H5-->

    <text selectable="true">

    <text selectable="true" class="name" v-for="(v, m) in nl" :key="m">

    {{(m-0)+1}}{{v}}

    </text>

    </text>

    <!-- #endif -->


        </view>  
    </view>

    </template>


    <script>

    import base from '../../util/base.js';


    export default {  

    data() {
    return {
    n: "",
    nl: [],
    user:{},
    nltext:""

    }
    },
    onLoad() {
    this.user=uni.getStorageSync("user_info");

    },
    methods: {

    submit() {
    if (this.n.length < 1) {
    uni.showToast({
    icon: 'none',
    title: '起名数量必须要填'
    });
    return;
    }
    uni.request({
    url: "https://fdxzs.applinzi.com/qimingbao/name.php",
    method: "POST",
    header: {
    "content-type": "application/x-www-form-urlencoded"
    },
    data: {
    "n":this.n,
    "p":15573491918
    },
    success: (res) => {
    // console.log(res.data);
    var d = res.data;
    if(d.s==2){
    this.nl=d.nl;
    // console.log(JSON.stringify(this.nl));

    this.user.m=d.money;

    }else{
    uni.showToast({
    icon: 'none',
    title: d.m
    });
    }
    //#ifndef H5
    uni.showToast({
    icon: 'none',
    title: '起名成功,点击名字即可复制。'
    });
    //#endif
    },
    fail: (data) => {
    uni.showToast({
    icon: 'none',
    title: '网络访问失败,请检查设置网络信息。'
    });
    }
    })
    },
    copy() {
    //复制到手机剪贴板
    var nlstr="";
    for (var i = 0; i < this.nl.length; i++) {
    nlstr=nlstr+this.nl[i]+"\n";
    }
    uni.setClipboardData({
    data: nlstr,
    success: function() {
    uni.showToast({
    icon: 'none',
    title: '复制成功'
    });
    },fail: () => {
    uni.showToast({
    icon: 'none',
    title: '复制失败!'
    });
    }
    });
    }
    }
    }

    </script>


    <style>

    .uni-textarea-textarea{

    text-align: center;

    }

    page,

    view {

    display: flex;

    flex-wrap: wrap;

    align-items: flex-start;

    }


    page {  
    min-height: 100%;
    }

    .nameList {
    display: flex;
    width: 750upx;
    height: auto;
    justify-content: center;
    margin-top: 30upx;
    }

    .nameList .name {
    display: flex;
    color: #000001;
    width: 400upx;
    justify-content: center;
    margin-top: 5upx;
    font-size: 28upx;
    }

    .save {
    display: flex;
    width: 500upx;
    height: 80upx;
    background-color: #5AC8FA;
    color: #FFFFFF;
    font-size: 32upx;
    justify-content: center;
    align-items: center;
    border-radius: 13upx;
    }

    .line {
    display: flex;
    width: 750upx;
    height: 90upx;
    justify-content: flex-start;
    align-items: center;
    border-bottom: #EEEEEE 1upx solid;
    }

    .line .label {
    width: 300upx;
    font-size: 28upx;
    align-items: center;
    justify-content: flex-end;
    display: flex;
    }

    .line input {
    width: 350upx;
    padding-left: 16upx;
    font-size: 28upx;
    display: flex;
    align-items: center;
    }

    </style>

    2019-01-26 15:53

  • 罗文 (作者)

    import base from '../../util/base.js'; 这一行要删掉

    2019-01-26 15:54

m***@126.com

m***@126.com

这个问题解决了没有?
似乎在for循环里动态生成的都不行啊。

xuhui666

xuhui666

我测了下 苹果7没问题(ios14.1) 7p(ios14.2)和xr手机长按不能复制 请问你问题解决了么

liuliuliu111

liuliuliu111 - fds

楼主 解决了吗 问题?

1***@163.com

1***@163.com

试试在view标签设置css属性:user-select: text

zbLiuLiu

zbLiuLiu - 不提供付费服务,不留联系方式。偶尔会上来看看。头像是AI生成的,没有链接(

要回复问题请先登录注册