Comments (6)
Vue3的官方SSR相关的还没有稳定,以及相关生态,所以一直没有弄。
from gez.
刚试用了一下,反馈几个问题
- http服务我使用了koa,但是启动后访问页面报错,后发现renderMiddleware的签名如下
renderMiddleware(req: IncomingMessage, res: ServerResponse, next: (err: any) => void): Promise<void>;
需要手动包装一下,然后devMiddleware与hotMiddleware 没有看到相关签名。 经过修改后访问页面不报错了,但是显示notfound。 - 每次dev启动会在src目录下生成app.vue、entry-client.ts、entry-server.ts、shims-vue.d.ts 这几个文件。(我修改了目录,在src目录下建了新的文件夹,并把原有的这些文件放到了该新的文件夹中,执行dev命令后会生成新的这几个文件,内容也不一样)
ps: app.vue内容如下
<template>
<div class="app">
<h2>你好世界!</h2>
<p v-if="show" class="text" @click="close">
{{ installed ? '在客户端应该安装成功,点击我关闭!' : '未安装' }}
</p>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
name: 'app',
data() {
return {
installed: false,
show: true
};
},
mounted() {
this.installed = true;
},
methods: {
close() {
this.show = false;
}
}
});
</script>
<style lang="less" scoped>
.app {
padding: 100px;
text-align: center;
}
.text {
color: #999;
font-size: 14px;
cursor: pointer;
}
</style>```
from gez.
针对第一点,你可以看下 渲染器的知识,你不需要使用默认的中间件,直接使用底层的api调用。
from gez.
app.vue
、entry-client.ts
、entry-server.ts
、shims-vue.d.ts
这几个文件,是固定在src目录下面的。
基本目录/src
基本目录/dist/服务名称
如果你实在是想修改,可以这样去覆盖掉默认的目录
class MySSR extends SSR {
public get srcDir() {
// return super.srcDir;
return path.resolve('你的目录');
}
}
from gez.
感谢解答
第一点主要是webpack的dev和hot中间件是express,需要自行包装一下
from gez.
嗯,是的。网上有koa保证express中间件的例子。
from gez.
Related Issues (20)
- 又整理了些新的问题,希望大大能解决下。 HOT 3
- 大佬,问下生产环境如何部署?没搞过linux,实在是不会! HOT 2
- 在服务端接口请求API出错,想要跳转页面如何处理呢? HOT 1
- 突然发现 favicon.ico 会自动加载成路由,而不是图标 HOT 3
- 请问JS优化压缩怎么操作?或有什么方法吗? HOT 3
- genesis怎么调试 HOT 5
- 你好 有维护版本更新记录吗 现在想更不知道更新到哪个新版本 稳定 谢谢~ HOT 6
- 想问下,提供的功能块是否有浏览器兼容性要求,我在尝试时,对于IE浏览器并不友好,另外能否提供一个更全面点的demo HOT 1
- 2.0版本没有genesis-remote这个组件了?前端怎么调用 HOT 7
- 客户端渲染是否就不是微服务了。 HOT 7
- 关于Node端实现module federation,父子服务的关系 HOT 5
- 大佬求助,1.x升级到2.1出错 HOT 12
- 大佬,关于VueSSRServerPlugin为什么要自己去实现? HOT 2
- 2.1.0 build 发布求助 HOT 5
- 由于无法使用createBundleRenderer,没有vue ssr自带沙箱机制。应该怎么清除setTimeout之类的副作用 HOT 3
- 大佬您好,关于styleTagExtractCSS不包含其他UI库CSS HOT 8
- Webpack hot reload error
- 大佬救命!升级到2.3 HOT 3
- english docs HOT 1
- error in examples when `yarn install` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gez.