Skip to content

🐛 [Bug]: 在低代码平台组件的属性的ref里定义个名称,在其他组件的方法中调用this.$(名称),打印后获取到这个组件实例,但是给实例的其中某一属性赋值报错'set' on proxy: trap returned falsish for property 'text' #144

@xmh0604

Description

@xmh0604

Environment

谷歌浏览器 windows 11

Version

16.20.2

Version

最新的

Link to minimal reproduction

步骤1
步骤2
步骤3
1.在页面中的button组件属性的ref中命名“buttonTL”
2.在页面中的另外一个button组件的方法中,打印this.$("buttonTL"),预览页面点击按钮,获取到组件实例,但是直接给组件实例赋值buttonTL.text = "文案修改";就报错了 :TypeError: 'set' on proxy: trap returned falsish for property 'text'
at Object.onClickNew6 (:184:21)
at Proxy. (:74:30)
at _createElementVNode.onClick._cache.._cache. (:271:87)

Step to reproduce

步骤1
步骤2
步骤3
1.在页面中的button组件属性的ref中命名“buttonTL”
2.在页面中的另外一个button组件的方法中,打印this.$("buttonTL"),预览页面点击按钮,获取到组件实例,但是直接给组件实例赋值buttonTL.text = "文案修改";就报错了 :TypeError: 'set' on proxy: trap returned falsish for property 'text'
at Object.onClickNew6 (:184:21)
at Proxy. (:74:30)
at _createElementVNode.onClick._cache.._cache. (:271:87)

What is expected

我想问一下用获取组件实例,去操作这个组件实例的办法是否行得通?如果能行,能提供的正确操作的demo吗?如果不行,有类似替代这种操作方式的办法吗?

What is actually happening

No response

Any additional comments (optional)

No response

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions