美好的一天,我被要求将整个 VueJs 模板转换为纯 HTML 以在 Angular 中使用它。
我可以访问 Vue 的所有文件,实际上是整个代码库,但是有没有一种"快速"的方法将这些模板转换为常规 HTML?
没有工具。以下是基础知识:
:attribute="x"
或v-bind:attribute="x"
=>- 自定义属性的
[attribute]="x"
- 本机 HTML 属性的
[attr.attribute]="x"
- 双向绑定(输入)的
[(attribute)]="x"
- 自定义属性的
@event="x"
或v-on:event="x"
=>(event)="x"
v-for="(item, key) in items" :key="key"
=>*ngFor="let item of items;let key=index;"
v-if="x"
=>*ngIf="x"
v-else
参照在*ngIf
元素上移动:*ngIf="x; else other"
,在组件中的某个位置定义<ng-template #other>...other content here</ng-template>
如果您遇到边缘情况,请询问,我会更新答案.
您可能会发现这很有用。