账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    自定义小程序组件?
    49
    0

    新手求教,这是jquery方法,请问如何将这种方法转换成小程序组件。

    `var str = $("#goodIntroduction").text();
    var tempt = str;
    coverup();

    function coverup() {

     if (str.length > 17) {
         $("#goodIntroduction").text(tempt.slice(0, 17) + "...");
     }
     var readmore = "<a onclick='showmore()'  style='color: orange;'>查看更多↓</a>"
     $("#goodIntroduction").append(readmore);

    }

    function showmore() {

     $("#goodIntroduction").text(str);
     var readmore = "<a onclick='coverup()'  style='color: orange;'>收起↑</a>"
     $("#goodIntroduction").append(readmore);

    }`

    `<div id="goodIntroduction">

    在漫无边际的海水上漂流,偶尔抬头能看见熟悉的日月星辰。因为我不知道下辈子是否还能遇见你,所以我今生才会那么努力把最好的给你。 陪伴,是最长情的告白;而声音,是最温柔的陪伴!

    </div>`

    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 自杀前夜 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部