vue

获取父组件

this.$parent

获取子组件

//设置
v-ref:ele

//获取
this.$refs.ele

相应修改组件

this.$set('data.value', newvalue)

延迟回调

1. created()钩子函数进行的DOM操作一定要放在Vue.nextTick()的回调函数中
2.在数据变化后要执行的某个操作,而这个操作需要使用随数据改变而改变的DOM结构的时候,这个操作都应该放进Vue.nextTick()的回调函数中。

this.$nextTIck

兼容IE1

  • babel-polyfill兼容新接口
  • vue-resource问题

处理路由

this.$route.query
this.$route.path

this.$router.replace({path, query})

使用vue-resource注意

  • 不同浏览器返回数据格式可能不一样
Vue.http.interceptors.push((request, next) => {
    next(response => {
        if (typeof response.data == 'string' && typeof response.headers['content-type'] == 'string' && response.headers['content-type'].indexOf('application/json') === 0) {
            try {
                response.data = JSON.parse(response.data)
            } catch (err) {
                console.log(err)
            }
        }
    })
});
posted @ 2017-07-07 20:14  JinksPeng  阅读(159)  评论(0编辑  收藏  举报