首页 > 其他分享 >[个人用] 常用工具

[个人用] 常用工具

时间:2022-09-05 16:47:23浏览次数:46  
标签:obj 个人 key const null 常用工具 id

对象合并

const obj = {
  id: null,
  count: null,
  completed: null,
};
// 假设这是接口返回的对象
const data = {
  id: 1,
  count: 2,
  completed: 3,
  otherParam:{
    // 返回的其他无用字段
  }
};
Object.keys(obj).forEach((key) => {
  obj[key] = data[key];
});

无用字段不会进入obj对象中

vue2.7以下使用volar

// tsconfig.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "allowJs": true,
    "paths": {
      "@/*": ["src/*"]
    }, // 使vscode识别@路径
    "outDir": "./",
    "jsx": "preserve"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"],
  "vueCompilerOptions": {
    "target": 2
    // "target": 2, // For Vue version <= 2.6.14
  }
}

标签:obj,个人,key,const,null,常用工具,id
From: https://www.cnblogs.com/UmaruChan/p/16658678.html

相关文章