可能有用3

1.移动端文字居中

第一种方式 有时有用

display:flex;
align-items:center; 
justify-content:center;

第二种方法

原文 http://www.pianshen.com/article/8324300015/

transform: scale(.5);
display: flex;
align-items: center;
justify-content: center;

注意:既然使用缩放,则所有的大小,宽高数值扩大一倍;

2.js直接比较时间

//javascript可以直接比较时间字符串的大小

var aaa="2007-01-02 13:03:05"
var bbb="2007-01-02 13:02:05"
console.log(aaa>bbb)

var aaa="20171201235959"
var bbb="20071201235959"
console.log(aaa>bbb)

3.vue中style加上scoped

<style type=" " scoped>

原文 http://www.imooc.com/wenda/detail/557850

scoped不是使得.vue组件样式不受外样式影响,而是使得.vue样式不影响其他.vue组件样式。
  1、是你想在.vue组件修改其他组件样式,所以才不起作用
  2、你的样式被外面的样式覆盖了  
  3、是属性的样式名没有写对。样式不起作用就上面三个方面原因。

4.vscode文件名不同颜色代表的意思

红色,未加入版本控制; (刚clone到本地)
绿色,已经加入版本控制暂未提交; (新增部分)
蓝色,加入版本控制,已提交,有改动; (修改部分)
白色,加入版本控制,已提交,无改动;
灰色:版本控制已忽略文件。

5.keepAlive

参考地址 https://segmentfault.com/q/1010000018010659/

                https://www.jianshu.com/p/0b0222954483

重点是App.vue里面是否有根据路由mete进行keep-alive包裹呢?

<keep-alive>
  <router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
类似这样
export default [
  {
    path: '/',
    name: 'home',
    component: Home,
    meta: {
      keepAlive: true // 需要被缓存
    }
  }, {
    path: '/:id',
    name: 'edit',
    component: Edit,
    meta: {
    zdy:true, keepAlive:
false // 不需要被缓存 } } ]

路由大法不错,不需要关心哪个页面跳转过来的,只要 router.go(-1) 就能回去,不需要额外参数。

然而在非单页应用的时候,keep-alive 并不能有效的缓存了

6.全局钩子函数---某个路由的钩子函数---路由组件的钩子

beforeEach---beforeEnter---beforeRouteEnter

https://www.cnblogs.com/WQLong/p/8135553.html

beforeRouteEnter(to, from, next){
...
next();
}

beforeRouteUpdate(to, from, next){
...
next();
}

beforeRouteLeave(to, from, next){
...
next();
}

必须加上 next()
next('/')
next({ path: '/' })
next中可以传入query 这这些钩子函数中不能找到this
beforeRouteLeave 可以获取到this
其他的不能获取到this
可以在这些钩子函数中设置更改to.meta.keepAlive/from.meta.zdy
然后
created(){
  console.log(this.$route.meta.keepAlive)  
}

activated() {
   console.log(this.$route.meta.zdy)      
},

7.sessionStorage和localStorage存储对象和数组的时候

sessionStorage和localStorage存储对象和数组的时候

var arr = {a:1,b:2}};
sessionStorage.setItem('arr',JSON.stringify(arr));
var arr2 = JSON.parse(sessionStorage.getItem('arr'));
console.log(arr2);

对象/数组先转成json 获取的时候在转成对象。

8.移动端页面最底部元素margin-bottom在ios下失效,在安卓内正常

padding正常

或者写一个空白的div占位

9.git

git stash save 写成了git commit -m
想撤销commit但是又想保留代码
git reset --soft HEAD^
https://www.cnblogs.com/rxbook/p/10564837.html

git commit -m '信息'
信息内容写错了
git commit --amend -m "新的提交信息"
https://www.jianshu.com/p/4c80d447368c

git提交的时候 如果master上没有a、b文件 但是develop上有a、b文件
a文件是新建里的 里面引用了组件b (a文件是复制c出来的 c在master上有 但是不一致 master上的c没有引用b develop上的c引用了b
提交的时候 不会报冲突 但是会将b文件提交到master上 还不会显示 )

10.路径栏地址传值

例如http://123/abc/#/eles?com=完整的url&utm=123
但是直接获取com并不能完整的获取到这个url 会在第一个特殊字符处被截断 例如 # &
所以 传过来的时候就将特殊字符转义一下 #变为%23 &变为%26
这样就可以直接获取com的值了

posted @ 2019-07-18 16:41  啊嘟咔  阅读(133)  评论(0)    收藏  举报