8000 Migration from Vue2 to Vue3 with OptionAPI passing vm from outside not working anymore (data being a function) · Issue #13322 · vuejs/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Migration from Vue2 to Vue3 with OptionAPI passing vm from outside not working anymore (data being a function) #13322

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

Closed
valeriob opened this issue May 13, 2025 · 0 comments

Comments

@valeriob
Copy link

Vue version

3

Link to minimal reproduction

https://jsfiddle.net/superboy2k/qb3o7fka/1/

Steps to reproduce

I started using view since version 1 and i'm stuck on version 2 due to a missing feature.
We alwasys loved the fact that Vue is not invasive in my codebases, thank to this property we could evolve the viewmodels for many years with very good efficiency and no errors.

In vue2 we have a lot of code that follow this structure, and it works very well :

var pageViewModel = new PageViewModelClass( /* paramerters or seed from server side rendering*/ )
 var vueInstance = new Vue({
     el: "#domId",
     data: pageViewModel 
 });

I'm trying to migrate to vue3, but the following approach is not working anymore, and we really would not like to merge the business logic view model inside vue function, how can we keep using vue3 by passing an external view model to the vue instance ? The ideal would be something like this

   createApp({
      data() {
        return vm;
      },
    methods : vm
   }).mount('#app')

but the error reports "vue.esm-browser.js:2260 [Vue warn]: Property "increment" was accessed during render but is not defined on instance.
at " and ofc it does not work.

Thank you
long time vue lover looking forward to use vue3

What is expected?

i would like to make an instance of a view model and pass it to vue like we used to do with vue2.

What is actually happening?

not working

System Info

Any additional comments?

No response

@vuejs vuejs locked and limited conversation to collaborators May 14, 2025
@edison1105 edison1105 converted this issue into discussion #13324 May 14, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0