1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- Component({
- externalClasses: ['i-class'],
- relations: {
- '../tab/index': {
- type: 'child',
- linked () {
- this.changeCurrent();
- },
- linkChanged () {
- this.changeCurrent();
- },
- unlinked () {
- this.changeCurrent();
- }
- }
- },
- properties: {
- current: {
- type: String,
- value: '',
- observer: 'changeCurrent'
- },
- color: {
- type: String,
- value: ''
- },
- scroll: {
- type: Boolean,
- value: false
- },
- fixed: {
- type: Boolean,
- value: false
- }
- },
- methods: {
- changeCurrent (val = this.data.current) {
- let items = this.getRelationNodes('../tab/index');
- const len = items.length;
- if (len > 0) {
- items.forEach(item => {
- item.changeScroll(this.data.scroll);
- item.changeCurrent(item.data.key === val);
- item.changeCurrentColor(this.data.color);
- });
- }
- },
- emitEvent (key) {
- this.triggerEvent('change', { key });
- }
- }
- });
|