angularjs - 我可以在没有自定义标签或选择器的情况下包含 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>
以从控制台中删除错误。这种方法有什么陷阱吗?
解决方案
我相信,在您的情况下,您可以将限制从 更改E
为A
。
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
推荐阅读
- laravel - Laravel Eloquent 订购
- php - 如何将我的 Cordova 应用程序连接到包含 php 文件的现有 Web 服务器
- css - 如何在css中创建一个不规则的正方形?
- python - 如何在这里对不同的 n 值制作动画?
- google-chrome-extension - 获取输入值 Chrome 扩展
- node.js - 为什么我们必须不断地重新构建我们的 React 应用程序来测试更改?
- json - 使用带有 JSON 响应的 VBA 请求
- javascript - 监控使用 django 观看的视频
- r - 未定义的列
- performance - 如何使用遗传算法构建 10 个元素的排序网络?