vue项目的琐碎点

1.在封装axios的时候,需要提前考虑文件下载的时候Blob文件流的请求

  if(response.data instanceof Blob) return response.data
  const { data, message, success } = response.data
  if (success) {
    return data
  } else {
    Message({ type: 'error', message })
    return Promise.reject(new Error(message))
  }

2.在vue2中存在vue如果要给初始化后对象添加的属性的时候需要用到官方提供的$set的api

 const { rows, total } = await getRoleList(this.pageParams);
      this.list = rows; // 赋值数据
      this.pageParams.total = total;
      this.list.forEach((item) => {
        this.$set(item, "isEdit", false);
        this.$set(item, "editRow", { ...item });
      });

3.对象的合并以及添加新的属性

Object.assign(row, {
          ...row.editRow,
          isEdit: false,
        });

4.如果在配置动态路由的时候,需求是传参和不传参不固定的时候则需要,给动态路由配置一个?

大概和可选链的作用差不多

 {
    path: '/employee/detail/:id?',
    name: 'employeeDetail',
    component: () => import('@/views/employee/detail'),
    hidden: true
  },

你可能感兴趣的:(vue.js,javascript,前端)