首页 > 解决方案 > 我可以在没有自定义标签或选择器的情况下包含 angular 1 组件吗

问题描述

嗨,我有角度 1 组件:

angular.module('main').directive('globalNotification', (_, moment, $modal, Auth, Payments, adds) => ({
  restrict: 'E',
  replace: true,
  templateUrl: '/client/directive/global-global-notification/global-notification.html',

以前它在索引中呈现为<global-notification></global-notification>但现在我有 angular 1 和 vue js 一起工作,而 Vue 抱怨那个自定义组件,因为它与 vue 无关。

所以,问题我可以以某种方式呈现这样的组件<div global-notification></div>以从控制台中删除错误。这种方法有什么陷阱吗?

标签: angularjs

解决方案


我相信,在您的情况下,您可以将限制从 更改EA

restrict: 'A',
<div global-notification></div>

正如文档(https://docs.angularjs.org/guide/directive)所说:

'A' - only matches attribute name
'E' - only matches element name
'C' - only matches class name
'M' - only matches comment

推荐阅读