摘要: new router({ scrollBehavior (to, from, savaPosition) { if(savePosition) { //历史记录的前进后退记住的之前滚动到的位置 return savePosition } else { return {x: 0, y: 0} } // 阅读全文
posted @ 2017-07-29 17:39 啊友的前端历程 阅读(150) 评论(0) 推荐(0) 编辑
摘要: function deepCopy(p,c){ c=c || {}; for(var i in p){ if(p.hasOwnProperty(p[i])){ if(typeof(p[i]) 'object'){ c[i] = Array.isArray(p[i])?[]:{}; deepCopy( 阅读全文
posted @ 2017-07-29 14:50 啊友的前端历程 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 方法一:先把汉字用两个单字节字符代替,返回代替后的字符创长度 function getBytes1(str){ var str=str.replace(/[^\x00-\xff]/g,'**"); return str.length;} 方法二:先计算字符创长度并记录该值,循环字符串,若为汉字,长度 阅读全文
posted @ 2017-07-29 14:16 啊友的前端历程 阅读(6276) 评论(0) 推荐(0) 编辑
摘要: new router({ routes:[ { path: '/', conponent: home, name: 'Home', alias: '/index' },{ path: '/about', conponent: about, name: 'About', },{ path: '/doc 阅读全文
posted @ 2017-07-29 00:56 啊友的前端历程 阅读(446) 评论(0) 推荐(0) 编辑
摘要: new router({mode:'history', routes:[]}) 正常a标签hash模式得href='#/home',histroy模式用a标签会跳转链接刷新页面,这是因为a标签的默认行为 解决方式:用<router-link to='/home'></router-link>(不管是 阅读全文
posted @ 2017-07-29 00:19 啊友的前端历程 阅读(5259) 评论(0) 推荐(0) 编辑
摘要: 单页应用 使用步骤 安装模块 npm install vue-router --save 引入模块 import vueRouter from 'vue-router' 使用模块 Vue.use(vueRouter) 创建路由实例对象 let router=new vueRouter({ //配置参 阅读全文
posted @ 2017-07-29 00:05 啊友的前端历程 阅读(98) 评论(0) 推荐(0) 编辑