使用element的自定義tree組件


在使用elemnet-ui時,需要自定義tree的一些元素,采用 :render-content屬性來進行渲染這些元素,但是官網給的例子有一點小坑,

 renderContent:function(createElement, { node, data, store }) {
                var self = this;
                return createElement('span', [
                    createElement('span', node.label),
                    createElement('span', {attrs:{
                        style:"float: right; margin-right: 200px"
                    }},[
                        createElement('el-button',{attrs:{
                            size:"mini"
                        },on:{
                            click:function() {
                                console.info("點擊了節點" + data.id + "的添加按鈕");
                                store.append({ id: self.baseId++, label: 'testtest', children: [] }, data);
                            }
                        }},"添加"),
                        createElement('el-button',{attrs:{
                            size:"mini"
                        },on:{
                            click:function() {
                                console.info("點擊了節點" + data.id + "的刪除按鈕");
                                store.remove(data);
                            }
                        }},"刪除"),
                    ]),
                ]);
            }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM