When avalon calls another component within the component, it will appear that the < xmp > tag cannot be deleted when obtaining data asynchronously. Synchronization is fine.

js Code

function heredoc(fn) {
        return fn.toString().replace(/^[^\/]+\/\*!?\s?/, "").
        replace(/\*\/[^\/]+$/, "").trim().replace(/>\s*</g, "><")
    }
    var data = [{
            id: "1",
            title: "test1",
            children: [{
                id: "11",
                title: "test11",
                children: [{
                    id: "21",
                    title: "test21"
                }]
            }]
        },
        {
            id: "2",
            title: "test2"
        }
    ]

    var vm = avalon.define({
        $id: "test",
        treelist: []
    })

    setTimeout(function () {
        vm.treelist = data;
    }, 2000)
    avalon.component("tree", {
        template: heredoc(function () {
            /*
            <div>
                <ul>
                    <li ms-for="(index, el) in @tree | get(0)" ms-class="["test", el.id == 1 && "test2"]" ms-click="@openSubTree(el)">
                        <a ms-attr="[{href:el.title},(el.children != null && el.children.length > 0) && {title:el.title}]">{{el.title}}</a>
                        <xmp  ms-widget="{is:"tree-child", treeItem: el}"></xmp>
                    </li>
                </ul>
             </div>
             */
        }),
        defaults: {
            tree: [],
            openSubTree: function (el) {
                el.open = !el.open
            }
        }
    })

    avalon.component("tree-child", {
        template: heredoc(function () {
            /*
             <ul class="child-item">
                <li ms-for="(index, el) in @treeItem.children | get(0)">
                    <span ms-click="@openSubTree(el)">{{el.title}}</span>
                    <xmp  ms-widget="{is:"tree-child", treeItem: childitem}"></xmp>
                </li>
             </ul>
             */
        }),
        defaults: {
            treeItem: {},
            openSubTree: function (el) {
                el.open = !el.open
            }
        }
    })

html Code

<body ms-controller="test">
    <xmp  ms-widget="{is:"tree",tree:@treelist}"></xmp>
</body>

May.26,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3197f-4ea0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3197f-4ea0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?