Aurelia - Inline definition of HTML-only custom element

前端 未结 1 2175
南笙
南笙 2021-02-20 12:48

I have a recursive object in my Aurelia view model that looks like this:

Class BottomlessPit {
    Name: string = \'\';
           


        
1条回答
  •  爱一瞬间的悲伤
    2021-02-20 13:24

    OK this hurt my head a little bit but here's a way to enable defining inline html-only custom elements...

    https://gist.run?id=11ac077048cab0ad9979

    app.html

    
    

    app.js

    export class App {
      kid = {
        name: 'North West',
        parents: [
          {
            name: 'Kanye West',
            parents: []
          },
          {
            name: 'Kim Karsomething',
            parents: []
          }
        ]
      };
    }
    

    main.js

    import {relativeToFile} from 'aurelia-path';
    import {Origin} from 'aurelia-metadata';
    import {TemplateRegistryEntry, TemplateDependency} from 'aurelia-loader';
    
    // override the TemplateRegistryEntry's "template" property, adding
    // logic to process inline custom elements (eg