Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xmh0604 opened this issue Dec 13, 2023 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@xmh0604
Copy link

xmh0604 commented Dec 13, 2023

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

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: 🐛 [Bug]: Define a name in the ref of the attribute of the low-code platform component, call this.$ (name) in the method of other components, and obtain the component instance after printing, but give An error is reported when assigning a certain property of the instance 'set' on proxy: trap returned falsish for property 'text'

@chilingling
Copy link
Member

@xmh0604 我自测了下,使用 vue 官方文档的暴露属性即可在低代码平台生效

vue 官方示例:https://vuejs.org/guide/essentials/template-refs

使用的组件需要定义了 expose 暴露属性

<script setup>
import { ref } from 'vue'

const a = 1
const b = ref(2)

// Compiler macros, such as defineExpose, don't need to be imported
defineExpose({
  a,
  b
})
</script>

自测相关截图:
image
image

@chilingling chilingling self-assigned this Dec 13, 2023
@chilingling chilingling added the question Further information is requested label Dec 13, 2023
@chilingling
Copy link
Member

问题类 issue,已答复

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Question issue, answered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants