【问题标题】:Set property dynamically in Vue component for angular在 Vue 组件中为 Angular 动态设置属性
【发布时间】:2021-10-29 08:31:02
【问题描述】:

我阅读了这个thread 并创建了网络组件:

<my-vue-web-comp [userId]="1"></my-vue-web-comp>

当我设置静态道具时,它在 Angular 中运行良好。但是当我尝试动态设置属性时:

<my-vue-web-comp [userId]="{{ usersInfo.userId }}"></my-vue-web-comp>

我的属性 userId 在 web 组件中为空。看起来 Web 组件是在编译时转换的,而不是在运行时转换的。

我该如何解决这个问题?

【问题讨论】:

    标签: javascript angular typescript vue.js web-component


    【解决方案1】:

    我认为在 Angular 中你只能这样做

    <my-vue-web-comp [userId]="usersInfo.userId"></my-vue-web-comp>
    
    

    或者这个

    <my-vue-web-comp userId="{{ usersInfo.userId }}"></my-vue-web-comp>
    
    

    如果两者都不起作用,试试这个

    <my-vue-web-comp user-id="{{ usersInfo.userId }}"></my-vue-web-comp>
    
    

    【讨论】:

      猜你喜欢
      • 2019-10-20
      • 2016-11-07
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多