Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.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
Javascript 儿童是反应性的,但儿童的儿童不是反应性的-vue_Javascript_Typescript_Vue.js_Vuejs2_Vue Component - Fatal编程技术网

Javascript 儿童是反应性的,但儿童的儿童不是反应性的-vue

Javascript 儿童是反应性的,但儿童的儿童不是反应性的-vue,javascript,typescript,vue.js,vuejs2,vue-component,Javascript,Typescript,Vue.js,Vuejs2,Vue Component,当我有以下数据 private static _docFields: TreeData[] = [ { id: 0, id: NodeType.Annotation, label: 'Annotations', children: [], }, 如果我跟随,它是反应性的 ApiService.post( 'documentAnnotation/annotations', { projectId: AppStor

当我有以下数据

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">