Vue入门笔记 day3

2018-03-09  本文已影响0人  12345ss

复习

javascript
引入对象
import VueRouter from 'vue-router';
安装插件
Vue.use(VueRouter);挂载属性的行为
创建路由对象
let router=new VueRouter({
    routes:[
        {name:'xxx' path:'/xxx',组件}
    ]
});
将路由对象放到option中
newVue({
    router
})

axios

拦截器

token(扩展)

拦截器操作loading

import Vue from 'vue';
import Axios from 'axios';

//拦截器
Axios.interceptors.request.use(function(config) {
    //请求发起之前  显示loading
    MintUi.Indicator.open();
    return config;
})
Axios.interceptors.response.use(function(config) {
    //响应回来之后 隐藏loading
    MintUi.Indicator.close();
    return config;
})
Vue.prototype.$axios = Axios;

监视 watch

watch: {
    a: function (val, oldVal) {
      console.log('new: %s, old: %s', val, oldVal)
    },
    // 方法名
    b: 'someMethod',
    // 深度 watcher
    c: {
      handler: function (val, oldVal) { /* ... */ },
      deep: true
    },
上一篇 下一篇

猜你喜欢

热点阅读