js使用html2canvas实现屏幕截取的示例代码

前端之家收集整理的这篇文章主要介绍了js使用html2canvas实现屏幕截取的示例代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

整理文档,搜刮出一个js使用html2canvas实现屏幕截取的示例代码,稍微整理精简一下做下分享

<Meta charset="utf-8"> <Meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"> Test@H_<a href="https://www.jb51.cc/tag/301/" target="_blank" class="keywords">301</a>_6@ <style type="text/css"> *{ margin:0 auto; padding:0; } .btn{ width:100px; height:30px; line-height:30px; background:green; color:#fff; border-radius:10px; -webkit-border-radius:10px; text-align:center; display:block; text-decoration:none; } .container{ background:#e5e5e5; } </style> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script src="https://cdn.bootcss.com/html2canvas/0.4.1/html2canvas.js"></script> <script> <p>$(function(){<br /> $("#btn").click(function(){<br /> html2canvas($("#container"),{<br /> onrendered: function(canvas) {<br /> //把<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>到的<a href="https://www.jb51.cc/tag/tupian/" target="_blank" class="keywords">图片</a>替换到a<a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>的路径下载<br /> $("#download").attr('href',canvas.toDataURL());<br /> //下载下来的<a href="https://www.jb51.cc/tag/tupian/" target="_blank" class="keywords">图片</a>名字<br /> $("#download").attr('download','share.png') ;<br /> document.body.appendChild(canvas);<br /> }<br /> //可以带上宽高<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>你所需要的部分<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a><br /> //,// width: 300,// height: 300<br /> });<br /> });<br /> }); </p> </script> </head> <body> <div style="padding:10px 0"> <div class="btn" id="btn"><a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>屏幕</div> <p style="color:red; text-align:center;">先点击<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>屏幕后再点击截图下载</p> <div style="margin-top:10px"> <a href="javascript:;" rel="external <a href="https://www.jb51.cc/tag/nofollow/" target="_blank" class="keywords">nofollow</a>" class="btn" id="download">截图下载</a> </div> </div> <div class="container" id="container"> <p style="text-align:center">以下是测试<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a></p> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAZ2ElEQVR4Xu2d4Xoquw5DT9//oXs/6N20wCTjJTTO0Or8PU5sy7LiBMr++O+//z7/e5P/Pj95qB8fH5vZjfai9gp0Ix/KXs41FF8lD5<a href="https://www.jb51.cc/tag/cpu/" target="_blank" class="keywords">cpu</a>o+C0yw/yh/Ff8eaS3fwruqIbMOHUnTa0NRegUJpHMUPXUPxVfJw+aD7UCwu9hEABbUD1yhFpw1N7ZV0lcZR/NA1FF8lD5<a href="https://www.jb51.cc/tag/cpu/" target="_blank" class="keywords">cpu</a>g/FIgKgIHbwGqXotKGpvZKy0jiKH7qG4qvk4fJB96FYRAAUxA5eoxSdNjS1V1JWGkfxQ9dQfJU8XD7oPhSLCICC2MFrlKLThqb2SspK4yh+6BqKr5KHywfdh2Lx5wWgA+BRUWgTKkQc+VbypvG6ybi1n/JKTXPvyFvBivJK8UHxpdgqMSl5Dz8FOGPAFHQFRCXvjkagIqdgRXPvyFupodII1A/Fl2JL45nZz7gTAXhATilURyNEAF5vCYrhzGME4PV6DHegDdVRWEVhFTFxnV6UoBe/NF5apwMpU9q6gydnxCQTQIkeX0a0CWaPRcpeEQBQLGgaAXgGLFeAXAFuCFDBOuNpp0xqUEemB8UZMbFOAO+mojReZXQeEahjLzox0CafTTg0b2VaovVzNrOyFxUAZ34K3/AEsDLgleRV8lYKojTV1hpKROfJOasTjUvBnTauwiuX8DrzU/gWASheAZRCKQWJANwjoOAeAahjGAGIAOz2C23CTADPkDoPA3pI5A1gl+LfBs5CdezlGkVzBQAkmZiuvOIofMsEkAlgl/mZAHYhuhl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AIgB1thgsIwB1EDuwwgJQD1+3pIkrnpw+6F7UfvYiTHNXXrZX+lAeWCm+9OO2Cx40LhoTxVzlSASgOAHMCkKLS+3V4m7FHAF4RiUCsMEUqnCKYo3WKA1C/Tt90L2ofQSAVZfiGwGIANwQUITPRbh3O53pY5siZCvrMZMdGhflCJO8L2tFyHIFyBXghoBCoKOvGbTRZo2gfMlLEbmtNREAIGkrwVpJuEwAzyRZWY8/PQGAfm0zVcjgCq7jbwFcJ7BKXJd/pU7UtyKWNC4ak4tr//ZxTSxTrEY/CeZOxrEfLaDD5789IgB1NJU60WaLAHjqMXwDqG/fZ6kQyxVdBKCOpFKnCED9+mPFKhNAjdgRgBpOF6sIQB0r5boWAfDgi3aJANThigDUsYoAAKwUYoHtp6YRgDqSSp2spxr8J9lGmdGY6gjVLPMI+ICTQqwa1PtWEYB9jP5ZKHWizZZHQE89/geNN9jBGDVuegAAAABJRU5ErkJggg=="> </div> </body> </html> </pre> </div> <p>由于使用最新版本的html2canvas<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>屏幕有问题,所以上面使用的是v0.4.1版本进行测试。 </p> <p>注意事项: </p> <p>1.<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a>加载完之后再<a href="https://www.jb51.cc/tag/diaoyong/" target="_blank" class="keywords">调用</a>html2canvas。 </p> <p>2.<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>背景<a href="https://www.jb51.cc/tag/tupian/" target="_blank" class="keywords">图片</a>没有<a href="https://www.jb51.cc/tag/xiaoguo/" target="_blank" class="keywords">效果</a>(就算把背景<a href="https://www.jb51.cc/tag/tupian/" target="_blank" class="keywords">图片</a>转为base64也没有<a href="https://www.jb51.cc/tag/xiaoguo/" target="_blank" class="keywords">效果</a>)。 </p> <p>3.<img><a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>的<a href="https://www.jb51.cc/tag/tupian/" target="_blank" class="keywords">图片</a>需要转为base64,不然<a href="https://www.jb51.cc/tag/jiequ/" target="_blank" class="keywords">截取</a>没有<a href="https://www.jb51.cc/tag/xiaoguo/" target="_blank" class="keywords">效果</a>(网上<a href="https://www.jb51.cc/tag/sousuo/" target="_blank" class="keywords">搜索</a>了一下,好像都说是跨域问题)。</p> <p>以上就是本文的全部<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>,希望对大家的学习有所帮助,也希望大家多多<a href="https://www.jb51.cc/tag/zhichi/" target="_blank" class="keywords">支持</a>编程之家。</p><i class="glyphicon glyphicon-link"></i> 原文链接:https://www.f2er.com/js/36790.html</div> <div class="topcard-tags"><a href="https://www.f2er.com/tag/html2canvas/" class="tag_link" target="_blank">html2canvas</a><a href="https://www.f2er.com/tag/html2canvasshixianpingmujiequ/" class="tag_link" target="_blank">html2canvas实现屏幕截取</a><a href="https://www.f2er.com/tag/jsp/" class="tag_link" target="_blank">js</a><a href="https://www.f2er.com/tag/pingmujiequ/" class="tag_link" target="_blank">屏幕截取</a><a href="https://www.f2er.com/tag/jiequ/" class="tag_link" target="_blank">截取</a><a href="https://www.f2er.com/tag/jiequp/" class="tag_link" target="_blank">截取</a></div> <ul class="list-group"> <li class="list-group-item"><a href="https://www.f2er.com/js/36791.html" title="JavaScript编写棋盘覆盖代码详解">上一篇:JavaScript编写棋盘覆盖代码详解</a><a href="https://www.f2er.com/js/36788.html" title="使用canvas进行图像编辑的实例" class="text-muted pull-right">下一篇:使用canvas进行图像编辑的实例</a> </li> </ul> </div> </div> </div> <!-- row end --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4605373693034661" data-ad-slot="9144498553"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div> </div> </div> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <div class="title"><h1>猜你在找的JavaScript相关文章</h1></div> <div class="list_con"> <a href="https://www.f2er.com/js/997747.html" title="Javascript中的事件冒泡与捕获"><div class="title">Javascript中的事件冒泡与捕获</div> <div class="summary">事件冒泡和事件捕获 起因:今天在封装一个bind函数的时候,发现el.addEventListener函数支...</div> <time class="summary">作者:前端之家 时间:2021-02-22</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997746.html" title="搞懂js中小数运算精度问题原因及解决办法"><img class="lazy" src="https://www.f2er.com/images/np.jpg" data-original="https://www.f2er.com/res/2021/02-22/19/e40e1eb184cb2a5d8c5f6c5e730d8e82.png" title="" width="160" height="90" style="float:right;margin-left:30px;display:none;" /><div class="title">搞懂js中小数运算精度问题原因及解决办法</div> <div class="summary">js小数运算会出现精度问题 js number类型 JS 数字类型只有number类型,number类型相当于其...</div> <time class="summary">作者:前端之家 时间:2021-02-22</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997744.html" title="搞懂:前端跨域问题JS解决跨域问题VUE代理解决跨域问题原理"><div class="title">搞懂:前端跨域问题JS解决跨域问题VUE代理解决跨域问题原理</div> <div class="summary">什么是跨域 跨域 : 广义的跨域包含一下内容 : 1.资源跳转(链接跳转,重定向跳转,表单提...</div> <time class="summary">作者:前端之家 时间:2021-02-22</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997743.html" title="前端对base64编码的理解,原生js实现字符base64编码"><div class="title">前端对base64编码的理解,原生js实现字符base64编码</div> <div class="summary">@ &quot;TOC&quot; 常见对base64的认知(不完全正确) 首先对base64常见的认知,也是...</div> <time class="summary">作者:前端之家 时间:2021-02-22</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997742.html" title="搞懂:MVVM模型以及VUE中的数据绑定数据劫持发布订阅模式"><div class="title">搞懂:MVVM模型以及VUE中的数据绑定数据劫持发布订阅模式</div> <div class="summary">搞懂:MVVM模式和Vue中的MVVM模式 MVVM MVVM : 的缩写,说都能直接说出来 :模型, :视图...</div> <time class="summary">作者:前端之家 时间:2021-02-22</time> </a> </div> <div style="border-bottom: 1px solid #f4f4f4;margin-top:20px;"> <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-fr-2o+fp-dx-wx" data-ad-client="ca-pub-4605373693034661" data-ad-slot="4561116489"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div><div class="list_con"> <a href="https://www.f2er.com/js/997318.html" title="js判断浏览器是否支持webGL"><div class="title">js判断浏览器是否支持webGL</div> <div class="summary">起因是我之前开发的网页,用到了three.js制作了一个3d的旋转球体效果。 在各种浏览器上运行...</div> <time class="summary">作者:前端之家 时间:2021-02-14</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997317.html" title="js判断undefined和null"><div class="title">js判断undefined和null</div> <div class="summary">js判断undefined js判断null js判断null和undefined</div> <time class="summary">作者:前端之家 时间:2021-02-14</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997316.html" title="将文字自动转为banner打印形式的工具"><div class="title">将文字自动转为banner打印形式的工具</div> <div class="summary">http://patorjk.com/software/taag/</div> <time class="summary">作者:前端之家 时间:2021-02-14</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997315.html" title="聊一聊 bootstrap 的轮播图插件"><div class="title">聊一聊 bootstrap 的轮播图插件</div> <div class="summary">今天做工作的时候,轻车熟路的做完,又用到了bootstrap的轮播图,觉得有必要安利一下这个插...</div> <time class="summary">作者:前端之家 时间:2021-02-14</time> </a> </div> <div class="list_con"> <a href="https://www.f2er.com/js/997314.html" title="js实现图片无缝循环跑马灯"><div class="title">js实现图片无缝循环跑马灯</div> <div class="summary">html 代码 css js代码 function mylsRunHorseLight() { if (mylsTimer != null) { clearIn...</div> <time class="summary">作者:前端之家 时间:2021-02-14</time> </a> </div> <div style="border-bottom: 1px solid #f4f4f4;margin-top:20px;"> <ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-fr-2o+fp-dx-wx" data-ad-client="ca-pub-4605373693034661" data-ad-slot="4561116489"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div></div> </div> </div> </div> <!-- left end--> <!-- right --> <div class="col-sm-12 col-md-12 col-lg-3"> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">编程分类</label> <div class="cate mt-20"><a href="https://www.f2er.com/html/" title="HTML">HTML</a><a href="https://www.f2er.com/html5/" title="HTML5">HTML5</a><a href="https://www.f2er.com/js/" title="JavaScript">JavaScript</a><a href="https://www.f2er.com/css/" title="CSS">CSS</a><a href="https://www.f2er.com/jquery/" title="jQuery">jQuery</a><a href="https://www.f2er.com/bootstrap/" title="Bootstrap">Bootstrap</a><a href="https://www.f2er.com/angularjs/" title="Angularjs">Angularjs</a><a href="https://www.f2er.com/typescript/" title="TypeScript">TypeScript</a><a href="https://www.f2er.com/vue/" title="Vue">Vue</a><a href="https://www.f2er.com/dojo/" title="Dojo">Dojo</a><a href="https://www.f2er.com/json/" title="Json">Json</a><a href="https://www.f2er.com/electron/" title="Electron">Electron</a><a href="https://www.f2er.com/nodejs/" title="Node.js">Node.js</a><a href="https://www.f2er.com/extjs/" title="extjs">extjs</a><a href="https://www.f2er.com/express/" title="Express ">Express </a><a href="https://www.f2er.com/xml/" title="XML">XML</a><a href="https://www.f2er.com/es6/" title="ES6">ES6</a><a href="https://www.f2er.com/ajax/" title="Ajax">Ajax</a><a href="https://www.f2er.com/flash/" title="Flash">Flash</a><a href="https://www.f2er.com/unity/" title="Unity">Unity</a><a href="https://www.f2er.com/react/" title="React">React</a><a href="https://www.f2er.com/flex/" title="Flex">Flex</a><a href="https://www.f2er.com/antdesign/" title="Ant Design">Ant Design</a><a href="https://www.f2er.com/webfrontend/" title="Web前端">Web前端</a><a href="https://www.f2er.com/weapp/" title="微信小程序">微信小程序</a><a href="https://www.f2er.com/wxmp/" title="微信公众号">微信公众号</a><div class="clearfix"></div> </div> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <!-- f2er-rightads --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4605373693034661" data-ad-slot="7756441254" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">最新文章</label> <ul class="n-list"><li><a href="https://www.f2er.com/js/997747.html" title="Javascript中的事件冒泡与捕获" target="_blank">• Javascript中的事件冒泡与</a></li> <li><a href="https://www.f2er.com/js/997746.html" title="搞懂js中小数运算精度问题原因及解决办法" target="_blank">• 搞懂js中小数运算精度问题</a></li> <li><a href="https://www.f2er.com/js/997744.html" title="搞懂:前端跨域问题JS解决跨域问题VUE代理解决跨域问题原理" target="_blank">• 搞懂:前端跨域问题JS解决</a></li> <li><a href="https://www.f2er.com/js/997743.html" title="前端对base64编码的理解,原生js实现字符base64编码" target="_blank">• 前端对base64编码的理解,</a></li> <li><a href="https://www.f2er.com/js/997742.html" title="搞懂:MVVM模型以及VUE中的数据绑定数据劫持发布订阅模式" target="_blank">• 搞懂:MVVM模型以及VUE中的</a></li> <li><a href="https://www.f2er.com/js/997493.html" title="js实现横向跑马灯效果" target="_blank">• js实现横向跑马灯效果</a></li> <li><a href="https://www.f2er.com/js/997318.html" title="js判断浏览器是否支持webGL" target="_blank">• js判断浏览器是否支持webG</a></li> <li><a href="https://www.f2er.com/js/997317.html" title="js判断undefined和null" target="_blank">• js判断undefined和null</a></li> <li><a href="https://www.f2er.com/js/997316.html" title="将文字自动转为banner打印形式的工具" target="_blank">• 将文字自动转为banner打印</a></li> <li><a href="https://www.f2er.com/js/997315.html" title="聊一聊 bootstrap 的轮播图插件" target="_blank">• 聊一聊 bootstrap 的轮播图</a></li> </ul> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">热门标签 <span class="pull-right tx-12"> <a href="https://www.f2er.com/all" target="_blank">更多 ►</a></span> </label> <div class="topcard-tags"><a href="https://www.f2er.com/tag/guanbiyangao/" title="关闭广告" target="_blank">关闭广告</a><a href="https://www.f2er.com/tag/danduheaders/" title="单独headers" target="_blank">单独headers</a><a href="https://www.f2er.com/tag/fengzhuangdaima/" title="封装代码" target="_blank">封装代码</a><a href="https://www.f2er.com/tag/tishicuowu/" title="提示错误" target="_blank">提示错误</a><a href="https://www.f2er.com/tag/zhengshuzhengze/" title="整数正则" target="_blank">整数正则</a><a href="https://www.f2er.com/tag/fei0kaitou/" title="非0开头" target="_blank">非0开头</a><a href="https://www.f2er.com/tag/tiaoye/" title="跳页" target="_blank">跳页</a><a href="https://www.f2er.com/tag/chuyema/" title="出页码" target="_blank">出页码</a><a href="https://www.f2er.com/tag/antdtable/" title="antd table" target="_blank">antd table</a><a href="https://www.f2er.com/tag/tishiURLweizhuce/" title="提示URL未注册" target="_blank">提示URL未注册</a><a href="https://www.f2er.com/tag/gongzhonghaozhifu/" title="公众号支付" target="_blank">公众号支付</a><a href="https://www.f2er.com/tag/vuehashmoshi/" title="vue hash模式" target="_blank">vue hash模式</a><a href="https://www.f2er.com/tag/iSlider/" title="iSlider" target="_blank">iSlider</a><a href="https://www.f2er.com/tag/chepaijianpan/" title="车牌键盘" target="_blank">车牌键盘</a><a href="https://www.f2er.com/tag/xunhuantupian/" title="循环图片" target="_blank">循环图片</a><a href="https://www.f2er.com/tag/echartsshuangzhexian/" title="echarts 双折线" target="_blank">echarts 双折</a><a href="https://www.f2er.com/tag/zuoyoubuju/" title="左右布局" target="_blank">左右布局</a><a href="https://www.f2er.com/tag/DllPlugin/" title="DllPlugin" target="_blank">DllPlugin</a><a href="https://www.f2er.com/tag/duixiangchuangjian/" title="对象创建" target="_blank">对象创建</a><a href="https://www.f2er.com/tag/daziyouxi/" title="打字游戏" target="_blank">打字游戏</a><a href="https://www.f2er.com/tag/quanxuan/" title="圈选" target="_blank">圈选</a><a href="https://www.f2er.com/tag/lianglan/" title="两栏" target="_blank">两栏</a><a href="https://www.f2er.com/tag/yunhanshu/" title="云函数" target="_blank">云函数</a><a href="https://www.f2er.com/tag/mengban/" title="蒙版" target="_blank">蒙版</a><a href="https://www.f2er.com/tag/ES2020/" title="ES2020" target="_blank">ES2020</a><a href="https://www.f2er.com/tag/chuchuang/" title="橱窗" target="_blank">橱窗</a><a href="https://www.f2er.com/tag/wufenggundonglunbo/" title="无缝滚动轮播" target="_blank">无缝滚动轮播</a><a href="https://www.f2er.com/tag/sekuaipengzhuang/" title="色块碰撞" target="_blank">色块碰撞</a><a href="https://www.f2er.com/tag/zujianxiaohui/" title="组件销毁" target="_blank">组件销毁</a><a href="https://www.f2er.com/tag/wendangcaozuo/" title="文档操作" target="_blank">文档操作</a></div> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <!-- f2er-rightads --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4605373693034661" data-ad-slot="7756441254" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <!-- row end --> </div> <!-- right end --> </div> </div> <footer id="footer"> <div class="container"> <div class="row hidden-xs"> <dl class="col-sm-6 site-link"> <dt>最近更新</dt><dd><a href="https://www.f2er.com/faq/884225.html" title="jQuery选择伪元素:after" target="_blank">· jQuery选择伪元素:after</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884224.html" title="JavaScript随机颜色生成器" target="_blank">· JavaScript随机颜色生成器</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884223.html" title="JavaScript指数" target="_blank">· JavaScript指数</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884222.html" title="addResourceHandlers无法解析静态资源" target="_blank">· addResourceHandlers无法解析静态资源</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884221.html" title="如何将字节数组转换为MultipartFile" target="_blank">· 如何将字节数组转换为MultipartFile</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884220.html" title="在java中如何创建一个文件并写入内容?" target="_blank">· 在java中如何创建一个文件并写入内容?</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884219.html" title="星号*在Python中是什么意思?" target="_blank">· 星号*在Python中是什么意思?</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884218.html" title="Flask框架:MVC模式" target="_blank">· Flask框架:MVC模式</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884217.html" title="在JavaScript对象数组中按ID查找对象" target="_blank">· 在JavaScript对象数组中按ID查找对象</a><span class="text-muted pull-right">10-20</span></dd> <dd><a href="https://www.f2er.com/faq/884216.html" title="使用Javascript / jQuery下载文件" target="_blank">· 使用Javascript / jQuery下载文件</a><span class="text-muted pull-right">10-20</span></dd> </dl> <dl class="col-sm-4 site-link"> <dt>好站推荐</dt><dd> <a href="https://www.runoob.com" title="菜鸟教程(www.runoob.com)提供了编程的基础技术教程, 介绍了HTML、CSS、Javascript、Python,Java,Ruby,C,PHP , MySQL等各种编程语言的基础知识。 同时本站中也提供了大量的在线实例,通过实例,您可以更好的学习编程。" target="_blank">菜鸟教程</a></dd><dd> <a href="https://www.jb51.cc" title="编程之家(www.jb51.cc)是成立于2017年面向全球中文开发者的技术内容分享平台。提供编程导航、编程问答、编程博文、编程百科、编程教程、编程工具、编程实例等开发者最需要的编程技术内容与开发工具支持,与你一起学习编程,相信编程改变未来!" target="_blank">编程之家</a></dd><dd> <a href="https://www.f2er.com" title="前端之家 f2er.com 前端开发人员所需学习知识手册。" target="_blank">前端之家</a></dd></dl> <dl class="col-sm-2 site-link"> <dt>商务合作</dt> <dd><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=76874919&site=qq&menu=yes">联系我们</a></dd> </dl> </div> <div class="copyright"> Copyright © 2019 前端之家. 当前版本 V7.0.16<br> <span class="ml5">前端之家 版权所有 <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">闽ICP备13020303号-10</a></span> </div> </div> </footer> <script type="text/javascript" src="https://www.f2er.com/js/base.js"></script> </body> </html>