小编Dav*_*sov的帖子

当元素位于模态内部时,Angular ViewChildren 不起作用

当模板引用变量放置在模态中时(因此最初未定义),我无法使用 ViewChildren 访问模板引用变量。即使在将模态插入到 DOM 中之后,元素的 QueryList 的长度仍然为零。

  1. 我尝试注入 ChangeDetectorRef 然后使用 detectorChanges() 手动检测更改
  2. 我尝试过为 ViewChildren 使用 setter

这里的最小可重现示例: https ://stackblitz.com/edit/angular-whsdr6

对于上面的示例,我希望 console.log 返回一个对象,其结果属性是长度为 5 的数组(五个段落标记元素)。

javascript ng-bootstrap angular

5
推荐指数
0
解决办法
1577
查看次数

VueJS 2 + TypeScript:计算值未检测数据定义的属性

以下组件:

<template lang="html">
  <div>
    <p>{{ bar }}</p>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';

export const FooBar = Vue.extend({
  computed: {
    bar: function() {
      return this.foo;
    }
  },
  data: function() {
    return {
      foo: 'bar',
    };
  },
});

export default FooBar;
</script>
Run Code Online (Sandbox Code Playgroud)

导致类型错误:

13:19 Property 'foo' does not exist on type 'CombinedVueInstance<Vue, unknown, unknown, unknown, Readonly<Record<never, any>>>'.
    11 |   computed: {
    12 |     bar: function() {
  > 13 |       return this.foo;
       |                   ^
    14 |     }
    15 |   }, …
Run Code Online (Sandbox Code Playgroud)

javascript typescript vue.js vuejs2

5
推荐指数
1
解决办法
1327
查看次数

标签 统计

javascript ×2

angular ×1

ng-bootstrap ×1

typescript ×1

vue.js ×1

vuejs2 ×1