加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

有没有办法在Angular 2或更高版本的html上显示组件名称?

发布时间:2020-12-17 18:11:03 所属栏目:安全 来源:网络整理
导读:这个组件…… my-component pHello !/p/my-component …在html模板里面…. div class="myClass" my-component/mycomponent/div …会在客户端呈现这样的东西: div class="myClass" my-component pHello !/b /mycomponent/div 是否有一些如何不显示组件html标
这个组件……

<my-component>
   <p>Hello !</p>
</my-component>

…在html模板里面….

<div class="myClass">
   <my-component></mycomponent>
</div>

…会在客户端呈现这样的东西:

<div class="myClass">
   <my-component>
     <p>Hello !</b>
  </mycomponent>
</div>

是否有一些如何不显示组件html标签,但显示组件内部内容?就像是…

<div class="myClass">
      <p>Hello !</b>
</div>

解决方法

既然你有一个选择器,你可以尝试做

<div class="myClass">
   <div my-component></div>
</div>

否则,根据this page

Directives that replace their host element (replace: true directives in Angular 1) are not supported in Angular 2. In many cases these directives can be upgraded over to regular component directives.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读