avalon组件同名属性存在问题

avalon不同组件嵌套使用如果两个套件有相同属性名会存在问题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../lib/avalon.js"></script>
    <link href="./index.css" rel="stylesheet" />
    <script>

        var vm = avalon.define({
            $id:"test-ant",
            size:"small",
            shape:"circle-outline",
            type:"ghost"
        })
        avalon.component("ms-icon",{
            template:"<i ms-class='[\"anticon\",\"anticon-\"+@type]'></i>",
            defaults:{

                type:''
            }


        })
        avalon.component("ms-button",{

            defaults:{
                prefixCls:'ant-btn',
                type:undefined,
                htmlType:'button',
                shape:undefined,
                size:undefined,
                loading:false,
                className:'',
                sizeCls:function(){
                    if(this.size){
                        return this.prefixCls+"-"+({
                            large:'lg',
                            small:'sm'
                        })[this.size];
                    }
                    return ""
                },
                getCls:function(k){
                    return this[k]?this.prefixCls+"-"+this[k]:"";
                },

                buttonText:"test"
            },

            soleSlot:"buttonText",
            template:'<button ms-attr="{type:@htmlType}" ms-class="[@prefixCls,@sizeCls(),@getCls(\'type\'),@getCls(\'shape\'),@getCls(\'loading\')]"><slot name="buttonText"></slot></button>'
        })
    </script>
</head>
<body ms-controller="test-ant" style="padding: 50px">

<ms-button ms-widget="{type:@type}"><ms-icon ms-widget="{type:'search'}"></ms-icon></ms-button>
</body>
</html>

这样导致icon组件的type没法正常显示。
这个是bug还是设置有问题。

阅读 2.7k
2 个回答
<button ms-attr="{type:@htmlType}" ms-class="[@prefixCls,@sizeCls(),@getCls('type'),@getCls('shape'),@getCls('loading')]" is="ms-button" wid="w1472628149431" type="button" class="ant-btn ant-btn-sm ant-btn-ghost ant-btn-circle-outline" old-change-class="ant-btn ant-btn-sm ant-btn-ghost ant-btn-circle-outline "><!--slot:buttonText--><i ms-class="[&quot;anticon&quot;,&quot;anticon-&quot;+@type]" is="ms-icon" wid="w1472628149439" class="anticon anticon-ghost" old-change-class="anticon anticon-ghost"></i><!--slot-end:--></button>

我看到i标签已经有 anticon anticon-ghost

还不对吗

新手上路,请多包涵

不对哦。icon要显示的应该是anticon anticon-search

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进