Umbraco 14无头模式集成Vue3:配置与预览问题咨询
问题:Umbraco v14无头模式对接Vue3的配置与预览问题
背景与需求
- 基于Umbraco v14搭建CMS,通过内容交付API对接Vue3前端
- 核心需求:
- 后台可添加空白页面,插入「Hero 1」「产品展示」「图文模块」等预定义区块
- 区块填写信息后支持发布前预览效果
- Vue端获取已添加页面数据,遍历预定义区块并按自定义样式渲染
已完成配置
Umbraco后台操作
- 创建名为「Page Template」的文档类型,采用区块列表作为内容字段
- 定义「Hero Block 1」「Text Image Block」两个区块类型
- 可在Home节点下创建如「Contact」的页面,并为页面配置区块内容
Vue前端实现
- 通过内容交付API获取数据,请求代码:
async fetchPageData() { try { const response = await axios.get(`/umbraco/delivery/api/v2/content`); console.log(response.data.items) } catch (error) { console.error('Error fetching page data:', error); } } - 遍历
pageTemplate类型页面的区块并渲染,组件代码:<div v-for="block in pageData.blocks" :key="block.title"> <hero-block v-if="block.blockType === 'heroBlock'" :title="block.title" :subtitle="block.subtitle" :imageURL="block.imageUrl" :ctaButton="block.ctaButton" ></hero-block> <text-image-block v-if="block.blockType === 'textImageBlock'" :title="block.title" :text="block.text" :imageURL="block.imageUrl" ></text-image-block> </div>
技术咨询问题
- 上述对接方式是否为Umbraco无头模式对接Vue(或其他前端)的正确做法?
- 若不正确,请告知此类集成的通用工作流是什么?
- 发布前的实时预览功能需要注意哪些事项?
内容的提问来源于stack exchange,提问作者eligolf
相关产品推荐
相关产品推荐

