How to Scroll to bottom?

I am using vue-codemirror 6 with Vue3 and Typescript, how i can scroll to the bottom when load? this below not working.

        v-model="getMigrationSessionLog.message" />
// Codemirror EditorView instance ref
  const cm = shallowRef();

  const handleReady = (payload: any) => {
    cm.value = payload.view;
    const state = cm.value.state;
    const lines = state.doc.lines;
    cm.value.dispatch({ selection: { anchor: lines - 1, head: 5 }, scrollIntoView: true });

[Vue warn]: Error in component event handler: “RangeError: Selection points outside of document”

lines show exactly how many row of my text model.

anchor should hold a document offset, not a line number.

Also, setting the selection to cover most of the document seems like a weird way to scroll somewhere (especially since the selection head is still near the top of the document). Try including scrollTo in the options to EditorView, if this <CodeMirror> wrapper doesn’t make that impossible.