孩子们反应迟钝,但孩子们的反应迟钝-Vue

时间:2019-10-30 18:10:45

标签: javascript typescript vue.js vuejs2 vue-component

当我有以下数据时。

private static _docFields: TreeData[] = [
    {
      id: 0,
      id: NodeType.Annotation,
      label: 'Annotations',
      children: [],
    },

如果我按照以下说明进行操作,则它是反应性的。

ApiService.post(
          'documentAnnotation/annotations', { projectId: AppStore.projectId },
        ).then((responseData: KeyValue[]) => {
          // TODO: Can't there be a mapper which can transform the results?
          responseData.forEach((documentAnnotation) => {

            AppStore.docFields.find((x) => x.id === NodeType.Annotation)!.children!.push({
              label: documentAnnotation.value,
              value: documentAnnotation.key,
            });

          });
        });

但是当我有以下数据时,

private static _docFields: TreeData[] = [
    {
      id: '0.' + NodeType.Annotation,
      label: 'Annotations',
      nodeType: NodeType.Annotation,
      children: [{
        id: '0.' + NodeType.SinglePageAnnotation,
        label: 'Single',
        children: [],
        nodeType: NodeType.SinglePageAnnotation,
      }, {
        id: '0.' + NodeType.MultiPageAnnotation,
        label: 'Multiple',
        children: [],
        nodeType: NodeType.MultiPageAnnotation,
      }],
    },

而且我也遵循,它不是被动的。我该怎么办?

AppStore.docFields
        .find((x) => x.nodeType === NodeType.Annotation)!.children!
        .find((y) => y.nodeType === NodeType.SinglePageAnnotation)!.children!.push({
                  label: documentAnnotation.value,
                  value: documentAnnotation.key,
                });

我具有如下所示的绑定元素UI树。

<el-tree :data="AppStore.docFields">

0 个答案:

没有答案