Comments (8)
@Gorden-Wang 哦不用。。你可以看看 文档 provide/inject 这个章节。在fetch里面获取后可以在props.asyncData里面拿到,不过现在只能在 app.vue
拿到 我需要加一下在 layout/index.vue
也能拿到
from ssr.
from ssr.
Hi @zhangyuang
非常感谢团队能够开源此框架,我们正在调研看从Nuxt上迁移过来,基于这个Issue我这里可能有一些补充的场景,也麻烦帮忙解惑或提供建议:
<head>
标签中大多数可以通过ctx
根据不同的path
进行枚举出来,我这里有这样一种场景,需要根据page
的接口返回的数据,添加相关seo 或 社交媒体的标签:
这种些数据的获取来自 页面 的 fetch:
- 一种解决方案是在 layout上面去获取数据再传给页面;
- 或者有一个service来返回这些meta信息,将这个数据和页面主要数据进行分离。
感觉每种方案都有点别扭。看官方是否有一些思路或考虑加入功能的支持?
from ssr.
你这种情况是要在fetch之前获取数据,把数据在服务端获取挂到ctx上在layout获取即可
建议扫码加入微信群
from ssr.
http://doc.ssr-fc.com/docs/features$communication#Provide/Inject
from ssr.
[email protected] 支持 layout/index.vue
通过 props.fetchData
拿到 layout fetch 的数据 发布中,@Gorden-Wang
from ssr.
用法参考 http://doc.ssr-fc.com/docs/features$communication#props%20%E7%9B%B4%E5%87%BA%E6%95%B0%E6%8D%AE
from ssr.
[email protected] 支持
layout/index.vue
通过props.fetchData
拿到 layout fetch 的数据 发布中,@Gorden-Wang
👍,神速。
from ssr.
Related Issues (20)
- 框架怎么设置 productionSourceMap HOT 3
- vite编译超时 HOT 3
- 怎么引入element-plus HOT 14
- 通过 less loader 配置的 less 变量不生效 HOT 5
- 请问有没有 egg的服务端插件? 如果没有,后端想使用egg,该怎么做呢,谢谢。 HOT 5
- 访问未定义的路由时,server端代码报错
- 生产环境的antdv ui css 样式和开发环境不一致 HOT 4
- 引入 css文件 报错 HOT 17
- 请问启动后,isBrower找不到,编译报错怎么解决?谢谢 HOT 2
- npx ssr build --html 编译出错 HOT 1
- 使用midway-vue3-ssr模版在组件中访问public下的静态资源404 HOT 3
- antd5新版本的兼容性问题
- 新版本antd5兼容性问题 HOT 4
- ssr-plugin-react 新版本缺少src路径
- build:o 相关问题 HOT 9
- Pm2模式下, Require() of ES Module 报错 HOT 2
- AuthProvider? HOT 4
- 通过vite方式引入windiCSS失败 HOT 2
- Webpack IgnorewPlugin HOT 1
- 请教下如何将node_module依赖构建到产物中,从而减少远端部署文件大小 HOT 1
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 ssr.