我正在使用SPA(单页应用程序),我使用Vue框架开发了该应用程序.

  • 前端:Vue
  • 后端:NodeJs

In my application I have other sub-modules written in angular 4, I want to write the functionality provided by Vue in angular.
Here is the link which can explain the <slot> functionality.

有人能建议在Angular4之后实施同样的解决方案吗?

推荐答案

这就是所谓的转换,用ng-contentng-content来实现.

在线查看一些教程,例如https://scotch.io/tutorials/angular-2-transclusion-using-ng-content

这允许您创建如下组件:

@Component({
  selector: 'app-component',
  template: `<div class="container"><ng-content></ng-content></div>`
})
export class AppComponent {}

在HTML中:

<app-component>Some text</app-component>

将呈现为:

<div class="container">Some text</div>

你甚至可以说出ng-content个名字.如果要替换多个内容.比如-

<ng-content select="[card-body]"></ng-content>

Vue.js相关问答推荐

如何将$validator实例注入到使用组合API语法的Vue2.7应用程序中

如何在Vue 3中将动态特性从主零部件同步到子零部件

我如何使用vuejs访问彼此嵌套的json对象

Vue 3 在一个值更改问题后再次重新渲染每一行

Vue Js Composition Api 未定义(读取名称)

如何在 A-La-Carte 系统中使用 vuetify 加载程序时导入 vuetify/lib

如何 for each 用户分组聊天消息?

vuejs:将props传递给javascript中的组件?

Defer推迟执行,直到外部脚本加载到 Vue.js

如何使用 v-on:change 将输入文本传递给我的 vue 方法?

如何在 Vue.js 中使用 MaterializeCss?

Vue.js + Vuex:如何改变嵌套项状态?

使用 Vue.js (cdn) 在特定元素上切换显示/隐藏

更新 v-for 中使用的数组内的对象时,Vue js react性问题

为什么 v-model 不适用于数组和 v-for 循环?

VueJS错误避免直接改变props

如何使用 Vue Test utils 测试输入是否聚焦?

在 Chrome DevTools 中实时更改时 destruct 了 Vue.js 应用程序(Webpack 模板)的页面样式

vue-cli@3 没有可用于依赖类型的模块工厂:CssDependency

Mapbox 事件监听器