Giter VIP home page Giter VIP logo

Comments (1)

EdwardQ avatar EdwardQ commented on May 23, 2024
ams.block('tabs', {
	type: 'tabs',
    props: {
		// 配置tab可动态新增
        editable: true
    },
	options: {
		tab1: 'tab1标题',
		tab2: {
			label: 'tab2 延迟加载',
			// 配置延迟加载
			lazy: true,
			// 配置是否可关闭
			closable: true
		},
		tab3: {
			label: 'tab3 不可点击',
			// 配置不可点击
			disabled: true
		}
	},
	data: {
        // 新增tab计数
        tabIndex: '3',
        // 指定初始化时tab展示哪一个
        active: 'tab1'
    },
	on: {
		// 监听编辑事件
		edit: function(targetName, action) {
			if (action === 'add') {
				// 动态新增tab
                let newTabName = `tab${++this.data.tabIndex}`;
                ams.block(newTabName, fromBlock);

                this.block.blocks.push(newTabName);
                this.block.options[newTabName] = {
                    label: newTabName
                };
                this.data.active = newTabName;
            }
		}
	},
	blocks: {
		tab1: {
			type: 'component',
            options: {
                is: 'div',
                text: '我是tabs1的内容'
            },
			actions: {
                init() {
                    console.log('tab1-init-----')
                }
            }

		},
		tab2: {
			type: 'component',
            options: {
                is: 'div',
                text: '我是tabs2的内容'
            },
			actions: {
                init() {
                    console.log('tab2-init-----')
                }
            }

		},
		tab3: {
			type: 'component',
            options: {
                is: 'div',
                text: '我是tabs3的内容'
            },
			actions: {
                init() {
                    console.log('tab3-init-----')
                }
            }
		}
	}
})

from ams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.