在 Vue 组件中为 angular 动态设置属性 [英] Set property dynamically in Vue component for angular

查看:33
本文介绍了在 Vue 组件中为 angular 动态设置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I read this thread and created web-component:

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

当我设置静态道具时,它在 Angular 中工作正常.但是当我尝试动态设置属性时:

It works fine in Angular when I set static prop. But when I try to set property dynamically:

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

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

my property userId is empty in web-component. It looks like the web component is being converted at compiling and not at runtime.

我该如何解决这个问题?

How can I solve this problem?

推荐答案

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

I think in Angular you can only do this

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

或者这个

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

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

if both do not work try this

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

这篇关于在 Vue 组件中为 angular 动态设置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆