Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 字符串对象的数组。我们需要把它们的字符串去掉_Arrays_Angular_Object_For Loop_Pdfmake - Fatal编程技术网

Arrays 字符串对象的数组。我们需要把它们的字符串去掉

Arrays 字符串对象的数组。我们需要把它们的字符串去掉,arrays,angular,object,for-loop,pdfmake,Arrays,Angular,Object,For Loop,Pdfmake,我有一个字符串数组,实际上是对象 buildTaskMatrix(pages) { let allTasks = []; for (let i = 0; i < pages.length; i++) { const page = pages[i]; for (let j = 0; j < page.tasks.length; j++) { const task = page.tasks[j]; allTasks.push( `[{ text:

我有一个字符串数组,实际上是对象

  buildTaskMatrix(pages) {
let allTasks = [];
for (let i = 0; i < pages.length; i++) {
  const page = pages[i];
  for (let j = 0; j < page.tasks.length; j++) {
    const task = page.tasks[j];
    allTasks.push(
      `[{ text: task.panelName, fontSize: 5, colSpan: 2 },
      {},
      { text: task.panelQty },
      { text: task.panelWidth + 'x' + task.panelHeight },
      { text: task.substrateName, fontSize: 5, colSpan: 2 },
      {},
      { text: task.producingBranch, fontSize: 5, colSpan: 2 },
      {},
      { text: task.specialInstructions, fontSize: 5, colSpan: 3 },
      {},
      {}]`
    );
    // const test = allTasks[j][0].replace('"', '');
    // const test2 = test.slice(0, -1);
  }
}
return allTasks;
我试过了

taskMatrix[0].replace('"', '')
这似乎不起作用


阵列不能在一个位置容纳多个对象,但这对我来说是理想的解决方案。我的想法是,我用错误的方式处理这个问题,希望有人知道我做错了什么

您应该直接将对象推入数组,或者如果出于任何原因确实需要字符串,请使用JSON.parse()将JSON格式的文本字符串转换为JavaScript对象。但是,您需要正确地设置字符串参数,并确保文本字段是双引号。

您没有实际为对象的字符串数组,而是有一个字符串数组。由于使用了字符串数组,现在需要一个自定义字符串解析器将字符串转换为可以使用的对象。这种循环逻辑的用例很难理解。为什么不把物体放在第一位呢?这就是我最后要做的。我的方法非常愚蠢,所以让我们一起努力吧。但是首先,你能解释一下为什么
样式
会出现在
的未来版本中,但在
的现有版本中却没有出现吗?
taskMatrix[0].replace('"', '')