Skip to content

Component Methods #149

Closed
Closed
@a-Leong

Description

@a-Leong

I am wondering how I can utilize Ionic component methods, for example the scrollToBottom() method on IonContent. Prior to alpha 15 I was using template refs:

<template>
  <IonContent ref="ionContentRef">
    ...
  </IonContent>
</template>

<script lang="ts">
  ...
  setup() {
    const ionContentRef = ref()

    ...
    ionContentRef.value.scrollToBottom() // eg inside click handler
    ...

    return { ionContentRef }
  }
</script>

however this no longer works, throws an error that scrollToBottom — or any component method — is undefined. What is the best way to access component methods at this point?

Activity

michaeltintiuc

michaeltintiuc commented on Aug 27, 2020

@michaeltintiuc
Member

Interesting, not sure what could've caused this except for some initialization issues, but seems like now it's working as expected for you. The ref is a Vue object and as such they do not have methods, to access Ionic methods you'd do ionContentRef.value.$el.scrollToBottom()

a-Leong

a-Leong commented on Aug 27, 2020

@a-Leong
Author

Great, thank you for that insight!

michaeltintiuc

michaeltintiuc commented on Aug 27, 2020

@michaeltintiuc
Member

I will however entertain the idea of removing the need for the extra $el will give it a shot and see how it performs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Component Methods · Issue #149 · ModusCreateOrg/ionic-vue