Wow, so in order to migrate my existing project from Blaze to Vue, I’m going to have to rewrite the entire front end – and roll my own forms too – oh man that’s going to take a large amount of work.
The main obstacle is simple schema – I have a lot of validation logic and of course it dictates the shape of the data going into Mongo. Can I use simple schema and all it’s goodness with Vue?
Would switching to React be an easier “upgrade” path?
You can use Simple Schema but Autoforms is unfortunately tied up to Blaze. A partial workaround is to write a simple wrapper around Autoform so that you’ll still be using Autoform’s Blaze templates inside of your Vue components.
That said, I moved to Astronomy which doesn’t work with Autoforms anyways.
React provides Uniforms library which works with Simple Schema out of the box. We (vue-meteor community) didn’t write such a library for Vue yet.
I made some experiments and I’ve got a half baked forms generator, but it’s working with Astronomy and is too tied up to my code at the moment and doesn’t cover all use cases, as I didn’t write it with open sourcing it in mind.
I don’t mind rewriting my forms, as long as I can perform validation and have some sort of schema that can limit field lengths, and can do default values, etc.
Can someone help me get started with the demo project I posted?
To get my data reactive the vue-meteor-tracker package is the way to go right? Does it work well? Still seems a bit experimental but I think I can get it to work.
I also wonder, can I start with replacing the routing and then slowly change all my templates in to vue components and meanwhile the website will still work? Or would I need to change all my templates first. I mean can Blaze and Vue work together while migrating.
They can theoretically work well together while migrating, but you’d have to rewrite all your routing and provide a common parent Blaze template (initiated with <div v-blaze="">) that gets the data from Vue via Meteor Session and then dynamically loads particular Blaze template of your app with the data passed to it as props.
That is a workaround needed because of no possibility to pass props directly from Vue to Blaze.
So the following structure:
Vue component initialized by router
Blaze template serving as a bridge to pass data from Vue to Blaze
Dynamically loaded Blaze template depending on the route
You can also get rid of step 2 and pass the Session to your actual Blaze Templates but that will be more of rewriting.
It will be a worse case though if you work with nested routes in Flow Router. Vue-router has a great system of nested routes, but I didn’t try to make it work with Flow Router based app yet.
You can also use a mixin or injection (or extends: Component) to give access to this method on all the needed components.
Using Mixins or Injection is more verbose, but you gain the maintenance advantage of being more explicit (someone reading that code knows where appInfo comes from).
I got almost all blaze templates refactored into Vue now and it works great. However, I cant get meteor-vue-tracker to work at the moment for my project. Not receiving any data. I was thinking if someone could find what I do wrong since Im getting blind:
main.js
import '/imports/startup/client';
import Vue from 'vue'
import { Meteor } from 'meteor/meteor'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import VueMeteorTracker from 'vue-meteor-tracker'
Vue.use(VueMeteorTracker)
Vue.prototype.AppInfo = Meteor.App
import routes from '/imports/startup/client/routes.js'
import App from '/imports/ui/App.vue'
const router = new VueRouter({
mode: 'history',
routes,
})
Meteor.startup(() => {
new Vue({
render: h => h(App),
router,
}).$mount('app');
});
Printing undefined in the console.
Also getting TypeError: Cannot read property 'products' of undefined at some compressed code that looks like })(key, meteor.subscribe[key]);
I’m currently trying to setup a Vue application i’ve built, with Meteor and my problem at the moment is nothing is rendering. I’m using vue, vue-router and vuex from NPM. There is only one error in the console, which states:
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build. (found in <Root>)
Other than that everything seems to be working, but I’m staring at a white screen. I’m sure its something small i’m missing. Any help would be great. Thanks
Edit: I figured it out. Was missing render: h => h(App)
Now its rendering all black on my phone