zoukankan      html  css  js  c++  java
  • vue 仿新闻项目笔记

    1.main.js:

    import filters from 'XXX'

    Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))  //遍历过滤

    const router=new VueRouter({
    mode: 'history', //切换路径模式,变成history模式
    scrollBehavior: () => ({ y: 0 }), // 滚动条滚动的行为,不加这个默认就会记忆原来滚动条的位置
    routes
    });

    //axios的一些配置
    axios.interceptors.request.use();     //配置发送请求的信息

    axios.interceptors.response.use();    //配置请求回来的信息

    axios.defaults.baseURL = (process.env.NODE_ENV !=='production' ? config.dev.httpUrl:config.build.httpUrl);  //基本请求地址

    axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';  //设置请求头

    Vue.prototype.$http = axios  //其他页面在使用axios的时候直接  this.$http就可以了

    2.监听路由:

    watch:{
      $route(to,from){  }
    }

    3.vuex及vue-router常用方法示意:

    this.$store.dispatch('XXX');

    this.$route.path/this.$route.params

  • 相关阅读:
    OpenJ_Bailian
    Codeforces Global Round 2: D.Frets On Fire
    Gym 102035 NWU2019组队赛2.0
    Gym 102035H :Zuhair and the Dag
    Gym 102035E:New Max
    Gym
    Linux常用命令-总结
    Linux常用命令
    Linux常用命令
    分布式会话 拦截器 单点登录
  • 原文地址:https://www.cnblogs.com/wstmljf/p/9576503.html
Copyright © 2011-2022 走看看