资讯专栏INFORMATION COLUMN

H5 深度解析

Cympros / 2467人阅读

摘要:这个问题的解决方案有很多,个人觉得最简单方面的还是大漠大大的一种解决方案。

先科普一下,HTML5并不是一项技术,而是一个标准。
所以其实要么我们是作为理论派讨论HTML5标准,要么是作为实践派讨论HTML5标准在某浏览器的应用。
H5 实际上是一个解决方案,一个看起来酷炫的移动端onepage网站的解决方案
移动端的适配方案

rem适配
优点:

    1. 引用简单,布局简便
    2. 根据设备屏幕的DPR,自动设置最合适的高清缩放
    3. 有效解决移动端真实1px问题

但是绝不是每个地方都要用rem,rem只适用于固定尺寸!
在这里rem也是一种单位,并且可以为咱们的布局提供无线的变化,根据开发者的设定,它将会在不同的分辨率屏幕上展示不同的色彩。

这个单位的定义和em类似,不同的是em是相对于父元素,而rem是相对于根元素,当我们指定一个元素的font-size为2rem的时候,也就说这个元素的字体大小为根元素字体大小的两倍,如果html的font-size为12px,那么这个2rem的元素font-size就是24px。

    html {font-size: 12px;}
    h1 { font-size: 2rem; } 2*12 = 24px

    html {font-size: 16px;}
    h1 { font-size: 2rem; } 2*16 = 32px
单位 定义 特点
rem font size of the root element 以根元素字体大小为基准
em font size of the element 以父元素字体大小为基准
当然上边只是我们介绍rem简单的示例,具体运用到项目中我还需进行rem的计算,根据根元素的font-size通过Javascript来计算我们的rem单位适配
选取一个设备宽度作为基准,设置其根元素大小,其他设备根据此比例计算其根元素大小。比如使得iPhone6根元素font-size=16px。
设 备 设备宽度 根元素font-size/px 宽度/rem
iPhone5 320 计算 -
iPhone6 375 16 23.4375
iPhone7 375 16 23.4375
iPhone7plus 414 计算 -
根元素fontSize公式:width/fontSize = deviceWidth/deviceFontSize
下方为动态计算
  (function flexible (window, document) {
  var docEl = document.documentElement
  var dpr = window.devicePixelRatio || 1

  // adjust body font size
  function setBodyFontSize () {
    if (document.body) {
      document.body.style.fontSize = (12 * dpr) + "px"
    }
    else {
      document.addEventListener("DOMContentLoaded", setBodyFontSize)
    }
  }
  
  setBodyFontSize();
  // set 1rem = viewWidth / 10
  function setRemUnit () {
    var rem = docEl.clientWidth / 10
    console.log(rem)
    docEl.style.fontSize = rem + "px"
  }
  setRemUnit()

  // reset rem unit on page resize
  window.addEventListener("resize", setRemUnit)
  window.addEventListener("pageshow", function (e) {
    if (e.persisted) {
      setRemUnit()
    }
  })

  // detect 0.5px supports
  if (dpr >= 2) {
    var fakeBody = document.createElement("body")
    var testElement = document.createElement("div")
    testElement.style.border = ".5px solid transparent"
    fakeBody.appendChild(testElement)
    docEl.appendChild(fakeBody)
    if (testElement.offsetHeight === 1) {
      docEl.classList.add("hairlines")
    }
    docEl.removeChild(fakeBody)
  }
}(window, document))

上方的代码则是本人经常使用的rem计算方法,我们可以根据我们自己的需求设定基于多大的屏幕以及rem的换算倍率等

百分比方案
使用百分比布局大部分是可行的,它会让布局随着屏幕的大小自动缩放,而且不用写太多的css样式,以及js相关的计算操作,但是文字就存在非常大的问题了,由于文字是固定大小,在屏幕dpr变化的时候,文字的CSS像素不变,就导致了文字在页面中的占位发生了变化。这样的结果就是,文字过多或者屏幕dpr过小的时候,会发生溢出;但是如果按照小屏幕为基准,又会发生字体太小这种情况。
百分比在当前移动端适配排版的时候,更多地会作为section级别元素的兼容排版。这个也要和设计稿中的效果相关,如果设计稿中要求一个元素定宽,那么就直接用px来保证宽度就可以了。
vw方案
vw也是css的单位,1vw相当于1%,比如:浏览器视口尺寸为370px,那么 1vw = 370px * 1% =6.5px(浏览器会四舍五入向下取7),
我们来看看vw的浏览器和手机的兼容性问题
浏览器

手机

在移动端 iOS 8 以上以及 Android 4.4 以上获得支持,并且在微信 x5 内核中也得到完美的全面支持
vw自身将整个可见视口横向分成了100份,每一个单位就是1vw,这个单位最大的优势就是在移动端的时候,无论是竖屏或者横屏,vw永远都是针对于横向的,比rem的方案好在当屏幕大小发生变化(顺便兼容了以后的可调节屏幕大小的移动设备[手动斜眼])的时候,不会让页面崩掉。
对于移动设备来说,比如iphone6+的375pxCSS像素宽度,1vw就等于3.75px,通过这个单位可以解决上面的依赖于脚本绑定根元素font-size的问题,在竖屏和横屏下面都有比较好的效果

$w-base: 375px
$w-base-design: 750px
@function px2vw($px)
    @return ($px / $w-base-design) * 100vw

虽然vw可以得到很好的支持,但是不会得到视觉稿原本的像素值了。在后期进行维护的时候会增加很多很多很多麻烦,前期打怪爽,后期装备维护难

淘宝移动端适配方案

淘宝

移动端事件
click:单击事件,类似于PC端的click,但在移动端中,连续click的触发有200ms ~ 300ms的延迟
touchstart:手指触摸到屏幕会触发
touchmove:当手指在屏幕上移动时,会触发
touchend:当手指离开屏幕时,会触发
touchcancel:可由系统进行的触发,比如手指触摸屏幕的时候,突然alert了一下,或者系统中其他打断了touch的行为,则可以触发该事件
移动端常见问题

1px问题

   大家都知道我们再写web端适配的时候还需要兼容ie浏览器,这是因为浏览器的内核都不一样,而且我们的屏幕大小,屏幕厂商也是不一样,时常会发生缺少像素或者多像素现象,其实手机也一样屏幕大小不一,浏览器也是各式各样,拿iphone6为例,其dpr(device pixel ratio)设备像素比为2,css中一个1x1的点,其实在iphone6上是2x2的点,并且1px的边框在devicePixelRatio = 2的Retina屏下会显示成2px,在iPhone6 Plus下甚至会显示成3px。

这个问题的解决方案有很多,个人觉得最简单方面的还是大漠大大的一种解决方案。
使用postcss-write-svg插件

利用meta标签对viewport进行控制

2.删除默认的苹果工具栏和菜单栏

3.在web app应用下状态条(屏幕顶部条)的颜色 (iphone设备中的safari私有meta标签 ) 默认值为default(白色),可以定为black(黑色)和black-translucent(灰色半透明) 若值为“black-translucent”将会占据页面px位置,浮在页面上方

4.允许全屏模式浏览 (iphone设备中的safari私有meta标签 )

5.禁止了把数字转化为拨号链接 在iPhone上默认将电话号码变为超链接(蓝色字体)并且点击这个数字还会自动拨号

6.ios click点击事件延时300ms

7.移动端如何定义字体font-family

8.移动端字体单位font-size选择px还是rem (new)

9.移动端touch事件(区分webkit 和 winphone) (new)

更多问题

webApp与响应式区别
响应式:
    设计通过CSS3的MQ(Media queries),使网页在不同设备上都可以自动适应,从而具有更加优秀的表现效果。
    而且响应式设计不仅用在移动网站,在PC端也有不同屏幕的适配,而且移动端和PC端可以只使用一套代码,这就是全平台的响应式设计
Webapp:
    HTML5移动端(移动网站、混合应用、WebAPP)为了解决屏幕适配经常会使用响应式设计(流式布局、CSS3媒体查询),
    但是响应式设计并不是必须,也可以使用流式布局和remnant来解决移动端的屏幕适配问题
meta标签
META标签,是在HTML网页源代码中一个重要的html标签。META标签用来描述一个HTML网页文档的属性,例如作者、日期和时间、网页描述、关键词、页面刷新等

作用

META标签是HTML标记HEAD区的一个关键标签,它位于HTML文档的和之间(有些也不是在<head>和<title>之间)。它提供的信息虽然用户不可见,但却是文档的最基本的元信息。<meta>除了提供文档字符集、使用语言、作者等基本信息外,还涉及对关键词和网页等级的设定
</pre>
<pre>参考<br>手机端页面自适应解决方案—rem 布局进阶版<br>移动端Web页面适配方案<br>vh,vw单位你知道多少?
</pre>           
               
                                           
                       
                 </div>
            
                     <div class="mt-64 tags-seach" >
                 <div class="tags-info">
                                                                                                                    
                         <a style="width:120px;" title="服务器托管" href="https://www.ucloud.cn/site/active/new/uhybrid.html?ytag=seo#datacenter">服务器托管</a>
                                             
                         <a style="width:120px;" title="私有云" href="https://www.ucloudstack.com/?ytag=seo">私有云</a>
                                                                                                                                                 
                                      
                     
                    
                                                                                               <a style="width:120px;" title="解析深度学习" href="https://www.ucloud.cn/yun/tag/jiexishenduxuexi/">解析深度学习</a>
                                                                                                           <a style="width:120px;" title="深度学习解析" href="https://www.ucloud.cn/yun/tag/shenduxuexijiexi/">深度学习解析</a>
                                                                                                           <a style="width:120px;" title="云服务器的深度解析" href="https://www.ucloud.cn/yun/tag/yunfuwuqideshendujiexi/">云服务器的深度解析</a>
                                                                                                           <a style="width:120px;" title="h5" href="https://www.ucloud.cn/yun/tag/h5/">h5</a>
                                                         
                 </div>
               
              </div>
             
               <div class="entry-copyright mb-30">
                   <p class="mb-15"> 文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。</p>
                 
                   <p>转载请注明本文地址:https://www.ucloud.cn/yun/104325.html</p>
               </div>
                      
               <ul class="pre-next-page">
                 
                                  <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/104324.html">上一篇:老生常谈跨域问题</a></li>  
                                                
                                       <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/104326.html">下一篇:百度地图自定义控件</a></li>
                                  </ul>
              </div>
              <div class="about_topicone-mid">
                <h3 class="top-com-title mb-0"><span data-id="0">相关文章</span></h3>
                <ul class="com_white-left-mid atricle-list-box">
                             
                                                                                                    <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/42920.html"><b>2018微博词云项目<em>深度</em><em>解析</em></b></a></h2>
                                                     <p class="ellipsis2 good">摘要:最初产生这个项目的想法应该是在年月份,当时正在学习中,就萌生了这样一个想法从一个用户这一年发布的微博数据中,提取最有意义的个关键词。这些东西提交完就可以提交审核了,微博应用审核的速度还算比较快的,一两天基本差不多会审核完。

最初产生这个项目的想法应该是在2018年10月份,当时正在学习python中,就萌生了这样一个想法:从一个用户这一年发布的微博数据中,提取最有意义的top50个关键...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1517.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/15/small_000001517.jpg" alt=""><span class="layui-hide64">TANKING</span></a>
                                    <time datetime="">2019-07-30 18:42</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/120972.html"><b>性能优化全新思路!实践腾讯、字节、阿里、百度、网易等互联网公司项目实战+案例分析(附PDF源码)</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:不努力不奋斗,可能就会在基层一辈子止步不前。不过,只一句,如果你还在做这一行,还是一名程序猿媛,想走上坡路的你,也许我这到手的十几家一线互联网公司性能优化项目实战可能会对你有所帮助。                                                                                                          ...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1267.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/12/small_000001267.jpg" alt=""><span class="layui-hide64">ytwman</span></a>
                                    <time datetime="">2021-09-24 09:48</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/112940.html"><b>移动端布局与适配</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:实战之微信钱包腾讯服务界面网格布局是让开发人员设计一个网格并将内容放在这些网格内。对于移动端适配,不同的公司不同的团队有不同的解决方案。栅格系统用于处理页面多终端适配的问题。

grid实战之微信钱包 腾讯服务界面
CSS3网格布局是让开发人员设计一个网格并将内容放在这些网格内。而不是使用浮动制作一个网格,实际上是你将一个元素声明为一个网格容器,并把元素内容置于网格中。
移动端页面适配—...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1457.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/14/small_000001457.jpg" alt=""><span class="layui-hide64">Clect</span></a>
                                    <time datetime="">2019-08-29 14:08</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                           
                </ul>
              </div>
              
               <div class="topicone-box-wangeditor">
                  
                  <h3 class="top-com-title mb-64"><span>发表评论</span></h3>
                   <div class="xcp-publish-main flex_box_zd">
                                      
                      <div class="unlogin-pinglun-box">
                        <a href="javascript:login()" class="grad">登陆后可评论</a>
                      </div>                   </div>
               </div>
              <div class="site-box-content">
                <div class="site-content-title">
                  <h3 class="top-com-title mb-64"><span>0条评论</span></h3>   
                </div> 
                      <div class="pages"></ul></div>
              </div>
           </div>
           <div class="layui-col-md4 layui-col-lg3 com_white-right site-wrap-right">
              <div class=""> 
                <div class="com_layuiright-box user-msgbox">
                    <a href="https://www.ucloud.cn/yun/u-1582.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/15/small_000001582.jpg" alt=""></a>
                    <h3><a href="https://www.ucloud.cn/yun/u-1582.html" rel="nofollow">Cympros</a></h3>
                    <h6>男<span>|</span>高级讲师</h6>
                    <div class="flex_box_zd user-msgbox-atten">
                     
                                                                      <a href="javascript:attentto_user(1582)" id="attenttouser_1582" class="grad follow-btn notfollow attention">我要关注</a>
      
                                                                                        <a href="javascript:login()" title="发私信" >我要私信</a>
                     
                                            
                    </div>
                    <div class="user-msgbox-list flex_box_zd">
                          <h3 class="hpf">TA的文章</h3>
                          <a href="https://www.ucloud.cn/yun/ut-1582.html" class="box_hxjz">阅读更多</a>
                    </div>
                      <ul class="user-msgbox-ul">
                                                  <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/130830.html">tensorflow实现lstm</a></h3>
                            <p>阅读 2065<span>·</span>2023-04-26 00:01</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/122774.html">Owned-Networks:便宜VPS,1核/1G/30G SSD/1T/1Gbps/KVM/可选</a></h3>
                            <p>阅读 640<span>·</span>2021-10-27 14:13</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/118784.html">☀️在爬完一周的朋友圈后,我发现了.......惊人⚠️秘密</a></h3>
                            <p>阅读 1626<span>·</span>2021-09-02 15:11</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/112200.html">H5移动端调试—weinre</a></h3>
                            <p>阅读 3260<span>·</span>2019-08-29 12:52</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/107988.html">总结开发过程踩到的坑(五)(小程序篇)</a></h3>
                            <p>阅读 408<span>·</span>2019-08-26 12:00</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/106872.html">JAVASCRIPT FUNCTIONS</a></h3>
                            <p>阅读 2468<span>·</span>2019-08-26 10:57</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/106334.html">javascript代理模式</a></h3>
                            <p>阅读 3263<span>·</span>2019-08-26 10:32</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/105318.html">了解Webpack吗?</a></h3>
                            <p>阅读 2737<span>·</span>2019-08-23 18:29</p></li>
                                                
                      </ul>
                </div>

                   <!-- 文章详情右侧广告-->
              
  <div class="com_layuiright-box">
                  <h6 class="top-com-title"><span>最新活动</span></h6> 
           
         <div class="com_adbox">
                    <div class="layui-carousel" id="right-item">
                      <div carousel-item>
                                                                                                                       <div>
                          <a href="https://www.ucloud.cn/site/active/kuaijiesale.html?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/zYeoGo8M.png" alt="云服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/gpu.html?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/29R6rrOS.png" alt="GPU服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/kuaijiesale.html?ytag=seo#global-uhost"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/FFBiRWaT.png" alt="海外云主机">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloudstack.com/?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/VEgKnwRX.png" alt="私有云">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/new/uhybrid.html?ytag=seo#datacenter"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/Z1o6CMPK.png" alt="服务器托管">                                 
                          </a>
                        </div>
                                                                   
                    
                        
                      </div>
                    </div>
                      
                    </div>                    <!-- banner结束 -->
              
<div class="adhtml">

</div>
                <script>
                $(function(){
                    $.ajax({
                        type: "GET",
                                url:"https://www.ucloud.cn/yun/ad/getad/1.html",
                                cache: false,
                                success: function(text){
                                  $(".adhtml").html(text);
                                }
                        });
                    })
                </script>                </div>              </div>
           </div>
        </div>
      </div> 
    </section>
    <!-- wap拉出按钮 -->
     <div class="site-tree-mobile layui-hide">
      <i class="layui-icon layui-icon-spread-left"></i>
    </div>
    <!-- wap遮罩层 -->
    <div class="site-mobile-shade"></div>
    
       <!--付费阅读 -->
       <div id="payread">
         <div class="layui-form-item">阅读需要支付1元查看</div>  
         <div class="layui-form-item"><button class="btn-right">支付并查看</button></div>     
       </div>
      <script>
      var prei=0;

       
       $(".site-seo-depict pre").each(function(){
          var html=$(this).html().replace("<code>","").replace("</code>","").replace('<code class="javascript hljs" codemark="1">','');
          $(this).attr('data-clipboard-text',html).attr("id","pre"+prei);
          $(this).html("").append("<code>"+html+"</code>");
         prei++;
       })
           $(".site-seo-depict img").each(function(){
             
            if($(this).attr("src").indexOf('data:image/svg+xml')!= -1){
                $(this).remove();
            }
       })
     $("LINK[href*='style-49037e4d27.css']").remove();
       $("LINK[href*='markdown_views-d7a94ec6ab.css']").remove();
layui.use(['jquery', 'layer','code'], function(){
  $("pre").attr("class","layui-code");
      $("pre").attr("lay-title","");
       $("pre").attr("lay-skin","");
  layui.code(); 
       $(".layui-code-h3 a").attr("class","copycode").html("复制代码 ").attr("onclick","copycode(this)");
      
});
function copycode(target){
    var id=$(target).parent().parent().attr("id");
  
                  var clipboard = new ClipboardJS("#"+id);

clipboard.on('success', function(e) {


    e.clearSelection();
    alert("复制成功")
});

clipboard.on('error', function(e) {
    alert("复制失败")
});
}
//$(".site-seo-depict").html($(".site-seo-depict").html().slice(0, -5));
</script>
  <link rel="stylesheet" type="text/css" href="https://www.ucloud.cn/yun/static/js/neweditor/code/styles/tomorrow-night-eighties.css">
    <script src="https://www.ucloud.cn/yun/static/js/neweditor/code/highlight.pack.js" type="text/javascript"></script>
    <script src="https://www.ucloud.cn/yun/static/js/clipboard.js"></script>

<script>hljs.initHighlightingOnLoad();</script>

<script>
    function setcode(){
        var _html='';
    	  document.querySelectorAll('pre code').forEach((block) => {
        	  var _tmptext=$.trim($(block).text());
        	  if(_tmptext!=''){
        		  _html=_html+_tmptext;
        		  console.log(_html);
        	  }
    		 
    		  
    		 
      	  });
    	 

    }

</script>

<script>
function payread(){
  layer.open({
      type: 1,
      title:"付费阅读",
      shadeClose: true,
      content: $('#payread')
    });
}
// 举报
function jupao_tip(){
  layer.open({
      type: 1,
      title:false,
      shadeClose: true,
      content: $('#jubao')
    });

}
$(".getcommentlist").click(function(){
var _id=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
$("#articlecommentlist"+_id).toggleClass("hide");
var flag=$("#articlecommentlist"+_id).attr("dataflag");
if(flag==1){
flag=0;
}else{
flag=1;
//加载评论
loadarticlecommentlist(_id,_tid);
}
$("#articlecommentlist"+_id).attr("dataflag",flag);

})
$(".add-comment-btn").click(function(){
var _id=$(this).attr("dataid");
$(".formcomment"+_id).toggleClass("hide");
})
$(".btn-sendartcomment").click(function(){
var _aid=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
var _content=$.trim($(".commenttext"+_aid).val());
if(_content==''){
alert("评论内容不能为空");
return false;
}
var touid=$("#btnsendcomment"+_aid).attr("touid");
if(touid==null){
touid=0;
}
addarticlecomment(_tid,_aid,_content,touid);
})
 $(".button_agree").click(function(){
 var supportobj = $(this);
         var tid = $(this).attr("id");
         $.ajax({
         type: "GET",
                 url:"https://www.ucloud.cn/yun/index.php?topic/ajaxhassupport/" + tid,
                 cache: false,
                 success: function(hassupport){
                 if (hassupport != '1'){






                         $.ajax({
                         type: "GET",
                                 cache:false,
                                 url: "https://www.ucloud.cn/yun/index.php?topic/ajaxaddsupport/" + tid,
                                 success: function(comments) {

                                 supportobj.find("span").html(comments+"人赞");
                                 }
                         });
                 }else{
                	 alert("您已经赞过");
                 }
                 }
         });
 });
 function attenquestion(_tid,_rs){
    	$.ajax({
    //提交数据的类型 POST GET
    type:"POST",
    //提交的网址
    url:"https://www.ucloud.cn/yun/favorite/topicadd.html",
    //提交的数据
    data:{tid:_tid,rs:_rs},
    //返回数据的格式
    datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
    //在请求之前调用的函数
    beforeSend:function(){},
    //成功返回之后调用的函数
    success:function(data){
    	var data=eval("("+data+")");
    	console.log(data)
       if(data.code==2000){
    	layer.msg(data.msg,function(){
    	  if(data.rs==1){
    	      //取消收藏
    	      $(".layui-layer-tips").attr("data-tips","收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart-o"></i>');
    	  }
    	   if(data.rs==0){
    	      //收藏成功
    	      $(".layui-layer-tips").attr("data-tips","已收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart"></i>')
    	  }
    	})
    	 
       }else{
    	layer.msg(data.msg)
       }


    }   ,
    //调用执行后调用的函数
    complete: function(XMLHttpRequest, textStatus){
     	postadopt=true;
    },
    //调用出错执行的函数
    error: function(){
        //请求出错处理
    	postadopt=false;
    }
 });
}
</script>
<footer>
        <div class="layui-container">
            <div class="flex_box_zd">
              <div class="left-footer">
                    <h6><a href="https://www.ucloud.cn/"><img src="https://www.ucloud.cn/yun/static/theme/ukd//images/logo.png" alt="UCloud (优刻得科技股份有限公司)"></a></h6>
                    <p>UCloud (优刻得科技股份有限公司)是中立、安全的云计算服务平台,坚持中立,不涉足客户业务领域。公司自主研发IaaS、PaaS、大数据流通平台、AI服务平台等一系列云计算产品,并深入了解互联网、传统企业在不同场景下的业务需求,提供公有云、混合云、私有云、专有云在内的综合性行业解决方案。</p>
              </div>
              <div class="right-footer layui-hidemd">
                  <ul class="flex_box_zd">
                      <li>
                        <h6>UCloud与云服务</h6>
                         <p><a href="https://www.ucloud.cn/site/about/intro/">公司介绍</a></p>
                         <p><a href="https://zhaopin.ucloud.cn/" >加入我们</a></p>
                         <p><a href="https://www.ucloud.cn/site/ucan/onlineclass/">UCan线上公开课</a></p>
                         <p><a href="https://www.ucloud.cn/site/solutions.html" >行业解决方案</a></p>                                                  <p><a href="https://www.ucloud.cn/site/pro-notice/">产品动态</a></p>
                      </li>
                      <li>
                        <h6>友情链接</h6>                                             <p><a href="https://www.compshare.cn/?ytag=seo">GPU算力平台</a></p>                                             <p><a href="https://www.ucloudstack.com/?ytag=seo">UCloud私有云</a></p>
                                             <p><a href="https://www.surfercloud.com/">SurferCloud</a></p>                                             <p><a href="https://www.uwin-link.com/">工厂仿真软件</a></p>                                             <p><a href="https://pinex.it/">Pinex</a></p>                                             <p><a href="https://www.picpik.ai/zh">AI绘画</a></p>
                                             
                      </li>
                      <li>
                        <h6>社区栏目</h6>
                         <p><a href="https://www.ucloud.cn/yun/column/index.html">专栏文章</a></p>
                     <p><a href="https://www.ucloud.cn/yun/udata/">专题地图</a></p>                      </li>
                      <li>
                        <h6>常见问题</h6>
                         <p><a href="https://www.ucloud.cn/site/ucsafe/notice.html" >安全中心</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/recent/" >新闻动态</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/report/">媒体动态</a></p>                                                  <p><a href="https://www.ucloud.cn/site/cases.html">客户案例</a></p>                                                
                         <p><a href="https://www.ucloud.cn/site/notice/">公告</a></p>
                      </li>
                      <li>
                          <span><img src="https://static.ucloud.cn/7a4b6983f4b94bcb97380adc5d073865.png" alt="优刻得"></span>
                          <p>扫扫了解更多</p></div>
            </div>
            <div class="copyright">Copyright © 2012-2023 UCloud 优刻得科技股份有限公司<i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/">沪公网安备 31011002000058号</a><i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/"></a> 沪ICP备12020087号-3</a><i>|</i> <script type="text/javascript" src="https://gyfk12.kuaishang.cn/bs/ks.j?cI=197688&fI=125915" charset="utf-8"></script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?290c2650b305fc9fff0dbdcafe48b59d";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DZSMXQ3P9N"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-DZSMXQ3P9N');
</script>
<script>
(function(){
var el = document.createElement("script");
el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?99f50ea166557aed914eb4a66a7a70a4709cbb98a54ecb576877d99556fb4bfc3d72cd14f8a76432df3935ab77ec54f830517b3cb210f7fd334f50ccb772134a";
el.id = "ttzz";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(el, s);
})(window)
</script></div> 
        </div>
    </footer>
</body>
<script src="https://www.ucloud.cn/yun/static/theme/ukd/js/common.js"></script>
<<script type="text/javascript">
$(".site-seo-depict *,.site-content-answer-body *,.site-body-depict *").css("max-width","100%");
</script>
</html>