有赞商城总结

2019-07-17  本文已影响0人  Grit0821

首页

  1. ul列表触底加载更多数据
    使用外部UI库mint-uiinfinite-scroll无限滚动指令,实质就是滚动距底部一定距离,执行方法进行数据请求。
  2. Foot组件的点击切换和跳转其他页面
methods: {
    changeNav(list, index) {
      location.href = `${list.href}?index=${index}`;
    }
}

列表页(search.html)

  1. top按钮显现
    监听touchmove事件,document.doucumentElement.scrollTop > 200显现
  2. 点击top按钮滚动到顶部的过渡效果
    使用第三方库velocity-animate
import Velocity from 'velocity-animate'

toTop(){
  Velocity(document.body,"scroll",{duration: 1000})
}

vue组件通信的方式

  1. down-props
  2. 自定义事件 $emit()
  3. 全局事件bus
  4. vuex 状态管理

个人主页/收货地址管理

  1. 路由配置
    嵌套路由,在个人主页里面还嵌套有子路由
let routes = [{
  /* 路由配置 */
  path:'/',
  component: member,
},{
  path: '/address',
  component: address,
  /* 嵌套路由 */
  children:[{
    path: '',
    redirect: 'all' /* 重定向跳转到/all */
  },{
    name:'all',
    path:'all',
    component:all,
  },{
    name: 'form',
    path:'form',
    component:form,
  }]
}]
  1. 路由跳转的方式
toEdit(list){
  // this.$router.push({path:'/address/form'})
  // 编程式导航
  this.$router.push({name:'form',query:{
      type: 'edit',
      instance: list,
  }})
},
const store = new Vuex.Store({
  state:{
    lists: null,
  },
  mutations:{
    // 同步操作
    init(state,lists){
      state.lists = lists
    }
  },
  actions:{
    // 异步操作
    getLists(){
      axios.get(url.addressLists).then(res=>{
        // commit触发传入数据,触发init方法
        store.commit('init',res.data.lists)
      })
    }
}
上一篇 下一篇

猜你喜欢

热点阅读