Why the event handling cannot work in vue


#1

Hi,
I create a vue-meteor example, but the event cannot fire.
Follow is the github url:
https://github.com/SvenWangChina/meteor-vue-vue-router-ssr-example

Has anyone encountered something similar? Thanks


#2

Hmm yeah that’s weird, I haven’t had any issues like that. I don’t see anything wrong with your component code so there must be something wrong with your setup. Maybe take a look at Akryum’s example projects. You can also check out mine


#3

You may want to read this: Reactivity In Vue.js (And Its Pitfalls)


#4

I compare the two project, cannot find the reason…


#5

thanks。Let me see see.


#6

Didn’t seem to be a reactivity issue, the click event is simply not firing at all, with no errors either.


#7

You don’t have any client-side JavaScript, in its current state your app is SSR only. Please take a look at the vue-meteor-demo, and especially the src/index.js file.


#8

You are right. It resolved when I added the following code(Meteor.isClient):

import { Meteor } from 'meteor/meteor';

if (Meteor.isClient) {
    import './imports/client';
} else if (Meteor.isServer) {
    import './imports/server';
}

the client code is:

import { Meteor } from 'meteor/meteor'
import CreateApp from './app'

Meteor.startup(() => {
    CreateApp();
});

Thanks very much.