【问题标题】:Oracle-jet with typescript web component带有 typescript web 组件的 Oracle-jet
【发布时间】:2020-09-01 08:42:39
【问题描述】:

我已经使用 typescript run 创建了应用程序:

ojet create web-app-navbar --template=navbar --typescript

然后我创建了 web 组件运行:

ojet create components demo-card --typescript

ojet cli 已成功创建演示卡组件。 我想在 about 页面中添加演示卡组件,并且添加了 html 标签:

// IT IS about.ts
class AboutViewModel {

  constructor() {

  }

  /**
   * Optional ViewModel method invoked after the View is inserted into the
   * document DOM.  The application can put logic that requires the DOM being
   * attached here. 
   * This method might be called multiple times - after the View is created
   * and inserted into the DOM and after the View is reconnected
   * after being disconnected.
   */
  connected(): void {
    // implement if needed
  }

  /**
   * Optional ViewModel method invoked after the View is disconnected from the DOM.
   */
  disconnected(): void {
    // implement if needed
  }

  /**
   * Optional ViewModel method invoked after transition to the new View is complete.
   * That includes any possible animation between the old and the new View.
   */
  transitionCompleted(): void {
    // implement if needed
  }
}

export default AboutViewModel;
<!--
 Copyright (c) 2014, 2020, Oracle and/or its affiliates.
 The Universal Permissive License (UPL), Version 1.0
 -->
 <!-- IT IS about.html view -->
<div class="oj-hybrid-padding">
  <h1>About Content Area</h1>
  <div>
      To change the content of this section, you will make edits to the about.html file located in the /js/views folder.
  </div>
  <deno-card></deno-card>
</div>

但它没有显示在页面上。 如何将此组件添加到我的应用程序中?

【问题讨论】:

    标签: javascript oracle-jet


    【解决方案1】:

    import 'demo-card/loader' 添加到about.ts

    使用 ojet cli 时,系统会自动为您设置组件路径。 您需要添加import 'demo-card/loader' 以自动解析转译组件的正确路径。

    【讨论】:

    • 我认为他应该在 about.ts 中导入它,对吗?他在上面提到了这一点。
    • 是的,我自己正在学习教程,没有注意到不同的文件名。编辑它。谢谢@Ray!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 2023-03-20
    • 2019-11-29
    • 2019-08-20
    • 2016-10-05
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多