zoukankan      html  css  js  c++  java
  • vue项目基本流程

    一、做项目基本流程:

        1、规划组件结构

            Nav.vue

            Header.vue

            Home.vue.....

        2、编写对应路由

            vue-router

        3、具体些每个组件功能

        一些公共的文件jquery,jquery插件,一般在index.html文件里面引用

      分析项目需要的模块:

          vuex vue-router axios

      assets:  放置 静态文件 image,css,js

    二、

        watch:{//用来监视路由发生变化时触发

        $route(to,from){

          console.log(to.path)//to将要去的路由,from为原路由

          if(to.path=='/user-info'){

            this.$store.dispatch('show-header')//触发actions

          }

        }

    }

    ---------------------------------------------------

    三、axios:可以配置

        axios不能Vue.use(axios)

        axios.interceptors.request.use();//发送请求配置

        axios.interceptors.response.use();//接收请求配置

        axios.interceptors.request.use(function (config) { //配置发送请求的信息
        stores.dispatch('showLoading')
        return config;
        }, function (error) {
        return Promise.reject(error);
        });

        axios.interceptors.response.use(function (response) { //配置请求回来的信息
        stores.dispatch('hideLoading')
        return response;
        }, function (error) {

        return Promise.reject(error);
        });

        将axios放在vue的原型上

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

        axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';设置axios post头部信息,使用表格格式传输

  • 相关阅读:
    2020.10.23 19级training 补题报告
    2020.10.17 天梯赛练习 补题报告
    2020.10.16 19级training 补题报告
    2020.10.9 19级training 补题报告
    2020.10.10 天梯赛练习 补题报告
    2020.10.3 天梯赛练习 补题报告
    2020.10.2 19级training 补题报告
    第十届山东省ACM省赛复现补题报告
    VVDI Key Tool Plus Adds VW Passat 2015 Key via OBD
    Xhorse VVDI Prog Software V5.0.3 Adds Many MCUs
  • 原文地址:https://www.cnblogs.com/qdcnbj/p/8319872.html
Copyright © 2011-2022 走看看