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

After using notificationreactive as the type in typescript, the content of the notification component is readonly #876

Closed
liyifo opened this issue Aug 15, 2021 · 3 comments · Fixed by #878
Assignees
Labels
bug Something isn't working types

Comments

@liyifo
Copy link

liyifo commented Aug 15, 2021

This function solves the problem (这个功能解决的问题)

How can I dynamically modify the content of a component

Expected API (期望的 API)

If I modify the value, I will prompt TS2540: Cannot assign to 'title' because it is a read-only property.
What should I do?

@github-actions github-actions bot added the feature request New feature or request label Aug 15, 2021
@liyifo
Copy link
Author

liyifo commented Aug 15, 2021

image

@Volankey
Copy link
Collaborator

Volankey commented Aug 15, 2021

I think you should use like the follow code:

const notification = useNotification()
const instance =  notification.create({
          title: "Wouldn't it be Nice",
          description: 'From the Beach Boys',
          content: `1234`,
          meta: '2019-5-27 15:11',
          avatar: () =>
            h(NAvatar, {
              size: 'small',
              round: true,
              src: 'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg'
            }),
          onAfterLeave: () => {
            message.success("Wouldn't it be Nice")
          }
        })
instance.title = 'xxxx'

If you want to use it outside setup, refer to https://www.naiveui.com/en-US/os-theme/components/message#Q-&-A.

@Volankey
Copy link
Collaborator

NotificationReactive type will fix.

@Volankey Volankey added bug Something isn't working and removed feature request New feature or request labels Aug 15, 2021
@Talljack Talljack self-assigned this Aug 15, 2021
@Talljack Talljack added the types label Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants