lodash 按键赋值

2021-03-09  本文已影响0人  charmingcheng
const defaultForm = {
  title: "",
  cid: "0",
  slug: '',
  media: [],
  additional: [],
  summary: "",
  content: "",
  orders: 0,
  flag: "1",
  seo_title: "",
  seo_description: ""
};

export default {
  data() {
    return {
      formData: {}
    }
  }
}
async fetchData() {
  const response = await this.$request.get(`/product/${id}`);
  this.formData = this.$_.pick(response.data, Object.keys(defaultForm))
}


上一篇下一篇

猜你喜欢

热点阅读