avalon2 第一个demo

<!DOCTYPE html>

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    </head>
    <body ms-controller='test'>
        <h1>soleSlot的使用, 它会组件容器中innerHTML替换生成组件的slot元素</h1>
        <div  >
            <xmp :widget="{is:'ms-button'}" :click="@ddd" :attr="{title:@bb}">{{@bb}}</xmp>
            {{aaaa}}
            <p><button :click="@click">click</button></p>

        </div>

        {{name}}

        <script src="lib/jquery-1.8.3.min.js"></script>
        <script src="lib/avalon.js"></script>
        <script src="js/test.js"></script>
    </body>
</html>
var vm;

function initVm() {
    avalon.component('ms-button', {
        template: '<button type="button"><span><slot /></span></button>',
        defaults: {
            buttonText: "button"
        },
        soleSlot: 'buttonText'
    })
    avalon.ready(function() {
        vm = avalon.define({
            $id: 'test',
            aaa: {
                buttonText: "vm中的值"
            },
            bb: '动态内容',
            aaaa: '动态内1容',
            name: 'lslsl',
            ddd: function() {
                console.log('xxxx')
            },
            click: function() {
                vm.bb = '更新内容' + (new Date - 0)
            }
        })
        avalon.scan(document.body);
    });
}
$(function() {
    initVm();
});

 

posted on 2019-07-01 19:26  ..小树苗  阅读(104)  评论(0编辑  收藏  举报

导航