You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用t-component渲染OWL组件时出现Cannot read 'name'错误

问题分析与解决方法
  • 核心错误原因:组件注册名与调用名不匹配
    你注册组件时用的标识是seat_map_modal:

    registry.category("components").add("seat_map_modal", SeatMapTemplate);
    

    但在模板里调用时写的是seat_map_component:

    <t t-component="seat_map_component" />
    

    两者名称不对应,导致Owl框架找不到目标组件,触发了Cannot read properties of undefined (reading 'name')报错。

  • 直接修复方式
    把模板里的组件调用名改成注册时的seat_map_modal即可:

    <t t-if="showSeatMap">
        <t t-component="seat_map_modal" />
    </t>
    
  • 额外排查要点

    1. 确认组件类正确导入并继承Owl的Component:
      import { Component } from "@odoo/owl";
      
    2. 确认模板的t-name与组件的template属性完全一致,你的代码里my_module.SeatMapTemplate是匹配的,这部分没问题。
    3. 再核对manifest文件的资源声明,确保js和xml文件都正确加入到对应资产包中,比如:
      'assets': {
          'web.assets_backend': [
              'my_module/static/src/js/seat_map.js',
              'my_module/static/src/xml/seat_map_templates.xml',
          ],
      },
      
    4. 清理Odoo资产缓存,重启服务后刷新页面,避免旧缓存干扰组件加载。

内容的提问来源于stack exchange,提问作者Skriptonit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 19:35:55