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

[message] 在自定义组件中调用异常 #3118

Closed
k186 opened this issue Sep 2, 2024 · 2 comments
Closed

[message] 在自定义组件中调用异常 #3118

k186 opened this issue Sep 2, 2024 · 2 comments

Comments

@k186
Copy link

k186 commented Sep 2, 2024

tdesign-miniprogram 版本

1.6.0

重现链接

No response

重现步骤

// components/Message/Message.js
import Message from 'tdesign-miniprogram/message/index';
Component({
  
  /**
   * 组件的属性列表
   */
  properties: {},
  
  /**
   * 组件的方法列表
   */
  methods: {
    show (text, type = 'error') {
      Message[type]({
        context: this,
        content: text,
        duration: 2000
      });
    }
  }
})
<!-- components/Message/Message.wxml--> 
<t-message id="t-message" />

以上是自定义组件,这么做是为了后面替换UI库,message 自定义组件放在page里面,我在其他自定义组件需要调用自定义组件message的show方法,show方法体内去调用真实T-message组件的 api,提示 context 不对;

// 我看实现是下面的逻辑
  const page = getCurrentPages()
  return page[page.length - 1].selectComponent(`#${id}`)

image

期望结果

No response

实际结果

No response

基础库版本

No response

补充说明

No response

Copy link
Contributor

github-actions bot commented Sep 2, 2024

👋 @k186,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@k186
Copy link
Author

k186 commented Sep 2, 2024

。。。没有引用问题

@k186 k186 closed this as completed Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant