I came across Parasails.js documentation which mentions support for router
and virtualPages
, but lacks specifics on how to utilize these options.
I am familiar with the traditional Vue setup of importing Vue, VueRouter, and individual components directly into the .vue file.
However, when working with parasails.js, it seems like these parameters require undefined objects as they are not fully explained in the documentation. This leaves me guessing about their implementation.
This is what I have managed so far:
parasails.registerComponent('mainSearch', {
props: [
'prop1',
'prop2',
],
html5HistoryMode: 'history',
virtualPages: [
{ path: '/foo', component: 'page2' },
],
template: `
<div class="test">
<p>Test</p>
<router-link to="/foo">Foo</router-link>
<router-view />
</div>
`,
beforeMount: function() {
//…
// Attach any initial data from the server.
_.extend(this, SAILS_LOCALS);
},
mounted: async function(){
//…
},
beforeDestroy: function() {
//…
},
});
However, I encountered an error:
TypeError: In the HTML template (during render): Cannot read property 'matched' of undefined
Has anyone successfully used router
or virtualPages
in parasails.js and can provide guidance?
My next question pertains to passing components to virtualPages
. Do I simply specify the name of another parasails registered component as a string? Or do I need to include that component in the code and pass it as an object similar to VueRouter?
Thank you for any assistance!
EDIT
It seems that utilizing virtualPages
on a parasails component does not work as intended.
Instead, adding these properties to a parasails page appears to be the correct approach:
virtualPages: true,
html5HistoryMode: 'history',
virtualPageSlug: undefined,
virtualPagesRegExp: /^\/test\/?([^\/]+)?/,
Although the previous error has been resolved, the
<router-view></router-view>
element is still not updating correctly when clicking on <router-link to="/test/foo/">Foo</router-link>
.
A route was added to the project:
'/test/foo/' : {
view: 'pages/test'
},
Any insights on why my router-view is not updating properly?
The documentation definitely needs some updates as it currently feels like a guessing game at every stage.