Skip to content

work with Server Side Render #174

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
Penggggg opened this issue Oct 26, 2017 · 2 comments
Closed

work with Server Side Render #174

Penggggg opened this issue Oct 26, 2017 · 2 comments

Comments

@Penggggg
Copy link

Penggggg commented Oct 26, 2017

happened

when using @component with vue-server-renderer,the ssr code cannot find my custom static method in my custom component which is decorated by @component

version

  • vue: 2.5.2
  • vue-class-component: 6.0.0
  • vue-server-renderer: 2.5.2
  • vue-router: 3.0.1
  • typescript: 2.5.3
  • node: 7.6.0

detail

i want to run my custom static method in my custom component when the vue-router match this component in NodeJS witch is decorated by @component . But when the router has find this component, i can not find my static method in it.

code

Modal.component.ts

@Component({})
export default class Modal extends Vue {
  static asyncData( ) {
     // ... some code
  }
}

entry-server.ts

// main code
const matchedComponents = router.getMatchedComponents( );
matchedComponents.map(( Component: any ) => {
   console.log(  Component.asyncData );
  // it can find Modal Component, but the static method asyncData is undefined here
})
@Penggggg
Copy link
Author

ok guys. I found the other solutions.

I found my custom methods in Component.options.methods which is not static method

matchedComponents.map(( Component: any ) => {
   const { someMethod } = Component.options.methods;
})

@ktsn
Copy link
Member

ktsn commented Oct 26, 2017

dup of #135 and already exists PR at #146 for your infromation.

@ktsn ktsn closed this as completed Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants