Giter Club home page Giter Club logo

Comments (5)

ruleeeer avatar ruleeeer commented on May 29, 2024

Is it possible that the remote side was started using dev mode? Dev mode only supports host side, remote side must use serve mode to run

from vite-plugin-federation.

ruleeeer avatar ruleeeer commented on May 29, 2024

Is it possible that the remote side was started using dev mode? Dev mode only supports host side, remote side must use serve mode to run

If this is not the cause, a repository may need to be provided to help me locate the problem

from vite-plugin-federation.

jzfai avatar jzfai commented on May 29, 2024

ok, i will be sub a example to you for test

from vite-plugin-federation.

jzfai avatar jzfai commented on May 29, 2024
  1. git clone https://github.com/jzfai/micro-frontend-template.git
  2. pnpm i

you can run separately
pnpm run host:preview
pnpm run remote:preview

to click this to test
image

from vite-plugin-federation.

ruleeeer avatar ruleeeer commented on May 29, 2024

image

Your cors policy does not allow logins.

But I modified some of the source code to allow me to log in and run (just hoping to give me an out-of-the-box test case), and I reproduced your problem, sorry I've never used vuex, so I had to look at the vuex source code to find that vuex is bound to the vue app instance,Its implementation is probably here:https://github.com/vuejs/vuex/blob/main/src/store.js#L78

install (app, injectKey) {
    app.provide(injectKey || storeKey, this)
    app.config.globalProperties.$store = this

    const useDevtools = this._devtools !== undefined
      ? this._devtools
      : __DEV__ || __VUE_PROD_DEVTOOLS__

    if (useDevtools) {
      addDevtools(app, this)
    }
  }

Since host and remote are running on different vue app instances, when you use remote components, you can only use the store information that has been registered on the host side

There are two possible solutions for this:

  1. define a mutation test.js in the host side
  2. refer to this practice to re-register once

from vite-plugin-federation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.