Skip to content

onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). #12614

@skique

Description

@skique

Version

2.7.2

Reproduction link

codesandbox.io

Steps to reproduce

package.json:

"vue": "^2.6.11",
"@vue/composition-api": "^1.4.4",

demo.tsx

import { defineComponent, onMounted } from "@vue/composition-api";

export default defineComponent({
    setup(){
        console.log('setup初始化')
        onMounted(()=> {
            console.log('进入了mounted')
        })
    },
    render() {
        return <div>test</div>
    }
})

What is expected?

it works

What is actually happening?

[Vue warn]: onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().


after my project has builded,i got this errors

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