vue2.0小小记录

1、关于路由跳转方法:push

this.$router.push({name:'master',params:{id:'参数'}});
//name和params搭配,刷新的话,参数会消失
 this.$router.push({path:'/master',query:{id:'参数'}});
//path和query搭配,刷新页面的话,url中的参数不会丢失,query中的参数成了url中的一部分

 2、$nextTick,有点像setTimeOut(fn,0)这意思

data(){
    return{
       data:'asdasd'
      }
    },
  methods:{
    clickEmit(){ //点击触发
      this.data='22222222'; //这里可写一些数据处理逻辑
      console.log(this.$el.textContent); //asdasd,此时数据dom数据未更新
      this.$nextTick(function(){
        console.log(this.$el.textContent); //22222222 已更新
      });
    }
  },

3、import组件的时候看到的 @ 这个是路径别名,路径别名定义在 webpack.base.js中,也可自己定义。

  '~': resolve('src/view/catalogue')  //webpack.base.js

路由中import时就可以这么写

import first from '~/first' 

4、较大的静态资源建议放到项目根目录的 static 文件夹

posted @ 2018-03-01 15:04  黑夜蓝天  阅读(304)  评论(0编辑  收藏  举报