- 博客(10)
- 收藏
- 关注
转载 directive()自定义函数内参数的解析
*1,restrict:A:attributes;E:element;M:comment(注释);C:class *2,transclude:为true的时候,可以在模版中增加<divng-transclude></div>来保留标签内部内容.可以处理嵌套 *3,replace:是否替换指令中的内容,例:<div>replace内...
2017-10-25 14:22:00
207
转载 滚动行为
new router({ scrollBehavior (to, from, savaPosition) { if(savePosition) { //历史记录的前进后退记住的之前滚动到的位置 return savePosition } else { return {x: 0, y: 0} } //histor...
2017-07-29 17:39:00
110
转载 对象深拷贝
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(p[i],c[i]) ...
2017-07-29 14:50:00
123
转载 编写一个函数,求字符串的长度
方法一:先把汉字用两个单字节字符代替,返回代替后的字符创长度 function getBytes1(str){ var str=str.replace(/[^\x00-\xff]/g,'**"); return str.length;} 方法二:先计算字符创长度并记录该值,循环字符串,若为汉字,长度加1,最终返回长度 function getBytes2(str){ va...
2017-07-29 14:16:00
3230
转载 重定向和别名
new router({ routes:[ { path: '/', conponent: home, name: 'Home', alias: '/index' },{ path: '/about', conponent: about, name: 'About'...
2017-07-29 00:56:00
157
转载 hash和history模式
new router({mode:'history', routes:[]}) 正常a标签hash模式得href='#/home',histroy模式用a标签会跳转链接刷新页面,这是因为a标签的默认行为 解决方式:用<router-link to='/home'></router-link>(不管是hash还是history都支持) <rout...
2017-07-29 00:19:00
112
转载 vue-router
单页应用 使用步骤 安装模块 npm install vue-router --save 引入模块 import vueRouter from 'vue-router' 使用模块 Vue.use(vueRouter) 创建路由实例对象 let router=new vueRouter({ //配置参数 routes:[ { path:...
2017-07-29 00:05:00
77
转载 计算从现在到明年的倒计时(包含天,时,分,秒),每秒更新一次
function timeCount(){ var nowTime=Date.parse(new Date()); var toTime=Date.parse(new Date('2018 01 01')); var jiange=(toTime-nowTime)/1000; var day=Math.floor(jiange/3600/24); var h...
2017-07-25 17:51:00
290
转载 两个ajax请求都成功之后打印一个字符串的(要求请求均为异步)
方法一: $.when($.ajax({url: 'url_1',data: data, success: function() { console.log('aaaa'); }}),$.ajax({url: 'url_2', data: data, success: function(){ console.log('bbb') }})).done(function(){ ...
2017-07-25 17:30:00
259
转载 js 首先通过成绩从小到大进行排序,成绩相同者通过学号从大到小进行排序
function sort(arr,attr,attr2){ var len=arr.length;if(len<=1){ return arr;} var num=Math.floor(len/2); var numVal=arr[num][attr]; var numVal2=arr[num][attr2]; var numStu=arr.splice(num,1); v...
2017-07-25 16:15:00
991
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人