mirror of
https://github.com/coollabsio/coolify-examples.git
synced 2026-02-25 16:58:58 +00:00
feat: added vue examples
This PR includes Vue examples, in particular: - Vue Spa - Vue Spa + Router - Vue using Sever Side Rendering with Express.js. Also updated the general Readme.
This commit is contained in:
8
vue/ssr/src/app.js
Normal file
8
vue/ssr/src/app.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createSSRApp } from 'vue';
|
||||
|
||||
export function createApp() {
|
||||
return createSSRApp({
|
||||
data: () => ({ count: 1 }),
|
||||
template: `<div @click="count++">Click me: {{ count }}</div>`,
|
||||
});
|
||||
}
|
||||
38
vue/ssr/src/server.js
Normal file
38
vue/ssr/src/server.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import express from 'express';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
import { createApp } from './app.js';
|
||||
|
||||
const server = express();
|
||||
server.use(express.static('public'))
|
||||
|
||||
server.get('/', (req, res) => {
|
||||
const app = createApp();
|
||||
|
||||
renderToString(app).then((html) => {
|
||||
res.send(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Vue SSR Example</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="module" src="./client.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">${html}</div>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
server.use(express.static('.'));
|
||||
|
||||
server.listen(3000, () => {
|
||||
console.log('Server listening on port 3000');
|
||||
});
|
||||
Reference in New Issue
Block a user