Single

js对象的几种创建方式_WEB前端开发

vue实现路由跳转的三种方式_WEB前端开发

vue实现路由跳转的三种方式:1、【】;2、【this.$router.push({ path:’/user’})】;3、【this.$router.replace(path:’/’)】。

一、字面量方式

var obj = {
    name: 'mm',
    age: 18,
    sayName: function() {    
        console.log(this.name);
    }
}

问题:创建多个对象时会造成代码冗余,很占内存空间。

二、工厂模式

问题:虽然解决了对象字面量创造对象冗余的问题,但是存在对象识别的问题,不能反映它们之间的内在关系。

三、构造函数模式

问题:解决了工厂模式的问题,但是相同方法重复创建就浪费了内存空间。

网页文件的头部标记有哪些_WEB前端开发

网页文件的头部标记有:1、,它是网页文件的标题,显示在浏览器的标题栏,用来说明文件的用途;2、<meta>,它用来定义页面信息的名称、关键字、作者等。</p> </blockquote> <p>四、原型模式</p> <p><img src="https://t.ki4.cn/2020/5/iQfYje.png" class="aligncenter"></p> <p>问题:共享方法,解决了构造函数的问题。但是当前实例的引用类型的属性被所有实例共享,一个变所有变。</p> <p>五、组合模式(构造函数+原型模式)</p> <p><img src="https://t.ki4.cn/2020/5/2Mfeya.png" class="aligncenter"></p> <p>这是常用的创建方式。</p> <p>通过构造函数模式定义实例属性,通过原型模式定义方法和共享的属性。</p> <p>推荐教程:js入门教程</p> <p>以上就是js对象的几种创建方式的详细内容,更多请关注ki4网其它相关文章!</p> <blockquote style="font-size:15px;background-color: #F5F5F5;border:none;padding: 5px;margin:15px;line-height: 1.6;text-indent: 2em;"> <p style="margin-bottom:5px;">HTML怎么实现下拉菜单_WEB前端开发</p> <p>HTML实现下拉菜单的方法:1、新建HTML文件为“select.html”;2、使用VSCode编辑器将其打开;3、在HTML的body标签里写入select标签;4、向select标签里添加选项标签option;5、使用浏览器打开即可。</p> </blockquote> </div> <div class="post-footer clearfix mt20"> <div class="post-tags"> <div class="article-categories"> <a href="https://www.39mo.com/tag/js" rel="tag">js</a><a href="https://www.39mo.com/tag/%e5%af%b9%e8%b1%a1" rel="tag">对象</a> </div> </div> </div> </div> <div class="another-posts thw-sept"> <div class="row no-gutters"> <div class="col-12 col-md-6"> <div class="another-post_block prev-post"> <div class="post-mini-img text-left"><a href="https://www.39mo.com/14/558514.php"> <img src="https://www.39mo.com/wp-content/uploads/2020/05/6ba761367b9c1e4f8afe12dc72688307.jpg" ></a></div> <div class="post-title"> <p><i class="fa fa-angle-left"></i> Previous post</p><a href="https://www.39mo.com/14/558514.php">css实现将网页变成黑白色_WEB前端开发</a> </div> </div> </div> <div class="col-12 col-md-6"> <div class="another-post_block text-right next-post"> <div class="post-title"> <p>Next post <i class="fa fa-angle-right"></i></p><a href="https://www.39mo.com/25/558518.php">vue实现路由跳转的三种方式_WEB前端开发</a> </div> <div class="post-mini-img text-right"><a href="https://www.39mo.com/25/558518.php"><img src="https://www.39mo.com/wp-content/uploads/2020/05/6ba761367b9c1e4f8afe12dc72688307.jpg"></a></div> </div> </div> </div> </div> <div id="comments" class="comments-area thw-sept"><h3 class="comments-heading text-center"><span><i class="fa fa-comments"></i> 暂无评论</span></h3></div> <div id="respond_com"></div> <div id="respond"> <h5 class="title-normal text-center" id="respond_com"><i class="fa fa-commenting"></i> 发表评论 <a id="cancel-comment-reply-link" href="javascript:;" class="btn btn-sm btn-warning" style="display:none;">取消回复</a> </h5> <form id="commentform" name="commentform" action="https://www.39mo.com/wp-comments-post.php" method="post"> <div class="row justify-content-center mb10"> <div class="col-md-3"> </div></div> <div class="row" id="comment-author-info"> <div class="col-md-4"> <div class="form-group comment-form-group"> <div class="input-group input-group-alternative mb-4"> <div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-user-circle"></i></span></div> <input type="text" name="author" id="author" class="form-control" value="" placeholder="昵称 *" tabindex="1"> </div> </div> </div> <div class="col-md-4"> <div class="form-group comment-form-group"> <div class="input-group input-group-alternative mb-4"> <div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-envelope"></i></span></div> <input type="email" name="email" id="email" class="form-control" value="" placeholder="邮箱 *" tabindex="2" /> </div> </div> </div> <div class="col-md-4"> <div class="form-group comment-form-group"> <div class="input-group input-group-alternative mb-4"> <div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-link"></i></span></div> <input type="text" name="url" id="url" class="form-control" value="" placeholder="网址" size="22" tabindex="3" /> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="media align-items-center"> <img alt='' src='https://gravatar.loli.net/avatar/?s=70&d=mm&r=g' srcset='https://gravatar.loli.net/avatar/?s=140&d=mm&r=g 2x' class='avatar avatar-70 photo avatar-default avatar-lg rounded-circle mb-4' height='70' width='70' loading='lazy'/> <div class="media-body"> <textarea class="form-control form-control-alternative" rows="3" name="comment" id="comment" tabindex="4" placeholder="你可以在这里输入评论内容..."></textarea> </div> </div> </div> </div> <div class="clearfix text-center"> <div class="comt-tips"><input type='hidden' name='comment_post_ID' value='558516' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> </div> <button class="btn btn-1 btn-outline-success mt20" name="submit" type="submit" id="submit" tabindex="5">发送评论</button> </div> </form> </div> </div> </div> </div> <div class=" container mt80"> <div class="row"> <div class="col-lg-12"> <h3 class="title-normal text-center">相关推荐</h3> </div> <div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/45/562130.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/971a5af105bb2a05cc85a285436ab9ee.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/45/562130.php" title="js如何准确判断变量的数据类型_WEB前端开发">js如何准确判断变量的数据类型_…</a></h4></div></div></div><div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/00/562056.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/3ce710b3ec8208af745fe75eba94d426.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/00/562056.php" title="php如何将对象转换为数组_后端开发">php如何将对象转换为数组_后端…</a></h4></div></div></div><div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/01/562016.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/9ef104f29c63b38ae1e34ca8afee3901.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/01/562016.php" title="史上最全的js、jQuery面试题_WEB前端开发">史上最全的js、jQuery面试题_WE…</a></h4></div></div></div><div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/51/561943.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/9f7672eadb7a5ddcbebc60030f0040c2.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/51/561943.php" title="详解javascript对象的数据属性与访问器属性_WEB前端开发">详解javascript对象的数据属性…</a></h4></div></div></div><div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/26/561564.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/bf4f6d96d5d7cc2c2b36f5a833baf500.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/26/561564.php" title="手把手教你如何实现前端的吸顶效果_WEB前端开发">手把手教你如何实现前端的吸顶…</a></h4></div></div></div><div class="col-md-4 card-related"><div class="card card-blog"><div class="card-header card-header-image"><a href="https://www.39mo.com/39/561307.php"><img class="img img-raised" src="https://www.39mo.com/wp-content/uploads/2020/07/194505fadd3f77d866f412b7c48b6dce.jpg"></a></div><div class="card-body"><h4 class="card-title"><a href="https://www.39mo.com/39/561307.php" title="手把手教你如何在HTML中引入外部JS文件_WEB前端开发">手把手教你如何在HTML中引入外…</a></h4></div></div></div> </div> </div> </section> <footer class="footer section"> <div class="container"> <hr class="hr-icon"> <a href="https://url.cn/TabGaBrN"><img src="https://i.ki4.cn/2020/08/25/7mpGx.png"></a> <p class="copyright text-center"> © <a href="https://www.39mo.com" target="_blank" title="39MO">39MO</a> 2020 | Theme by <a href="https://www.boxmoe.com" target="_blank">Boxmoe</a> <p>声明:本站的文章、图片、资源等来自互联网或者站长原创;版权归原作者所有,仅作为个人学习、研究以及欣赏!如有侵权,请联系i@ki4.cn删除!</p> Copyright © 2020 本站由<a href="http://www.keydatas.com/?aff=MNbMFj" target="_blank"><img src="https://pic.ki4.cn/gg/js.png" /> 简数采集 </a><a href="https://cloud.tencent.com/act/cps/redirect?redirect=1054&cps_key=05312f1563e6b48626d7c65410e669fb&from=console" target="_blank"><img src="https://pic.ki4.cn/gg/cloud.png" /> 腾讯云 </a><a href="https://www.bt.cn/?invite_code=MV9od3B1eHM=" target="_blank"><img src="https://pic.ki4.cn/gg/bt.ico" /> 宝塔系统 </a><a href="https://www.aliyun.com/sale-season/2020/procurement-new-members?userCode=ok4ov9yc" target="_blank"><img src="https://pic.ki4.cn/gg/al.ico" /> 阿里云 </a>强势驱动 <br>本页花费了0.743秒进行了49 次数据查询. <span ><br><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1277217282'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s96.cnzz.com/z_stat.php%3Fid%3D1277217282%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?7f829a8404686c6dee7864274eba17c7"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </span> </p> </div> </footer> </div> <div id="lolijump" data-toggle="tooltip" data-original-title="点我电脑会爆炸,不信试试看"> <img src="https://www.39mo.com/wp-content/themes/boxmoe/assets/images/top/lolisister1.gif"> </div> <div id="search"> <span class="close">X</span> <form role="search" id="searchform" method="get" action="https://www.39mo.com/"> <input type="search" name="s" value="" placeholder="输入搜索关键词..."/> </form> </div> <script src="https://www.39mo.com/wp-content/themes/boxmoe/assets/js/vendor.js"></script> <script src="https://www.39mo.com/wp-content/themes/boxmoe/assets/js/boxmoe.js"></script> <script src="https://www.39mo.com/wp-content/themes/boxmoe/assets/js/comments.js"></script> <script></script> </body> </html>