小编msp*_*erv的帖子

带有*ngFor的Angular 2模板引用变量

我有两个组件:列表和详细信息

列表组件中,我想渲染多个细节组件.

list.component.ts

@Component({
    selector: 'detail',
    templateUrl: './detail.component.html'
})
export class DetailComponent {
    @ViewChild('details') details;

    public items = {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

list.component.html

<detail *ngFor="let item of items" #details></detail>
Run Code Online (Sandbox Code Playgroud)

注意#details tempalte引用变量.我想访问所有细节组件.可以使#details变量成为一个数组吗?

angular

8
推荐指数
1
解决办法
6253
查看次数

如何强制 Vue 在路由更改时销毁并重新创建组件?

我在 Vue 路由器中的路线:

{ path: 'articles/create', component: () => import('Detail.vue') },
{ path: 'articles/:id/edit', component: () => import('Detail.vue') },
Run Code Online (Sandbox Code Playgroud)

如您所见,我Detail.vue在两条路线上渲染相同的 Vue 组件。

当 URL从例如变为时,如何“强制”Vue 销毁并重新创建Detail.vue组件?/articles/5/edit/articles/create

components render rerender vue.js

6
推荐指数
1
解决办法
5448
查看次数

获取 TypeScript 中的属性装饰器列表

class Test {
    @First()
    @Second()
    public someAttribute;
}

var t = new Test();
var decorators = t.getListOfAttributeDecorators("someAttribute");
console.log(decorators); // [First, Second]
Run Code Online (Sandbox Code Playgroud)

我想实现“getListOfAttributeDecorators”函数,但不知道如何实现。或者有没有其他方法可以获取属性装饰器列表?

typescript

3
推荐指数
2
解决办法
6348
查看次数

Vue 3 Composition API - 如何在 setup() 中指定道具

我为 Vue 2 编写了一个“加载状态”mixin:

export default {
  props: {
    loading: {
      type: Boolean,
      default: false
    },
  },
  data () {
    return {
      innerLoading: false,
    }
  },
  mounted () {
    this.innerLoading = !!this.loading
  },
  methods: {
    startLoading () {
      this.$emit('update:loading', this.innerLoading = true)
    },
    stopLoading () {
      this.$emit('update:loading', this.innerLoading = false)
    },
  },
  computed: {
    isLoading () {
      return !!this.innerLoading
    },
    isNotLoading () {
      return !this.innerLoading
    },
  },
  watch: {
    loading (loading) {
      this.innerLoading = !!loading
    },
  }
}

Run Code Online (Sandbox Code Playgroud)

我将此混合用于其他组件以保持loading …

vue.js vue-mixin vuejs3 vue-composition-api

0
推荐指数
1
解决办法
851
查看次数