express-vue
express-vue copied to clipboard
mounted is not working for rendered file
Description of Issue
Example vue file:
<template>
<div>
{{ isMounted }}
</div>
</div>
</template>
<script>
mounted: function() {
console.log('hello senpai');
this.isMounted = true;
},
</script>
Exposed Node route:
routes.get('/example', async (req, res) => {
try {
const data = {
variableOne: await getvariableOne(httpVal),
};
res.renderVue('example.vue',data);
} catch(e) {
logger.error(`Failed to generate`, e);
res.sendStatus(503);
}
})
server.js:
const vueOptions = {
rootPath: path.join(__dirname, '../../components/view'),
vueVersion: '2.6.14',
};
const expressVueMiddleware = expressVue.init(vueOptions);
app.use(expressVueMiddleware);
The isMounted variable here is always false when rendered and also not getting the console. I cannot use created lifecycle as data is manipulated after the template is rendered. Any sort of help will be appreciated.
Thanks.