This commit is contained in:
梁灏 2017-04-10 09:58:51 +08:00
parent b164f7c05c
commit 67c9b1c8b9
6 changed files with 87 additions and 44 deletions

View file

@ -1,13 +1,14 @@
<template> <template>
<Table :columns="columns1" :data="data1"> <div>
<div slot="header">头部</div> <Table :height="height" border :columns="columns1" :data="data2"></Table>
<div slot="footer">底部</div> <Button @click="height=800">change height</Button>
</Table> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
height: 200,
columns1: [ columns1: [
{ {
title: '姓名', title: '姓名',
@ -22,7 +23,27 @@
key: 'address' key: 'address'
} }
], ],
data1: [ data2: [
{
name: '王小明',
age: 18,
address: '北京市朝阳区芍药居'
},
{
name: '张小刚',
age: 25,
address: '北京市海淀区西二旗'
},
{
name: '李小红',
age: 30,
address: '上海市浦东新区世纪大道'
},
{
name: '周小伟',
age: 26,
address: '深圳市南山区深南大道'
},
{ {
name: '王小明', name: '王小明',
age: 18, age: 18,

View file

@ -1,42 +1,56 @@
<template> <template>
<Row> <Tabs value="name1" :animated="false">
<Col :span="12"> <Tab-pane label="标签一" name="name1">
<Tabs type="card" closable @on-tab-remove="handleTagRemove"> <Table :columns="columns1" :data="data1"></Table>
<Tab-pane label="标签一" v-if="tab0">标签一的内容</Tab-pane> </Tab-pane>
<Tab-pane label="标签二" v-if="tab1">标签二的内容</Tab-pane> <Tab-pane label="标签二" name="name2">
<Tab-pane label="标签三" v-if="tab2">标签三的内容</Tab-pane> <Table :columns="columns1" :data="data1"></Table>
</Tabs> </Tab-pane>
</Col> <Tab-pane label="标签三" name="name3">
<Col :span="12"> <Table :columns="columns1" :data="data1"></Table>
<Tabs type="card" closable @on-tab-remove="handleTagRemove"> </Tab-pane>
<Tab-pane :label="tab.label" v-for="tab of tabs" :key="tab">{{tab.content}}</Tab-pane> </Tabs>
<Button size="small" slot="extra" @click="addTab">添加</Button>
</Tabs>
</Col>
</Row>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
tabs:[ columns1: [
{label:'标签0',content:'标签内容0'}, {
{label:'标签1',content:'标签内容1'}, title: '姓名',
{label:'标签2',content:'标签内容2'}, key: 'name'
},
{
title: '年龄',
key: 'age'
},
{
title: '地址',
key: 'address'
}
], ],
tab0: true, data1: [
tab1: true, {
tab2: true name: '王小明',
} age: 18,
}, address: '北京市朝阳区芍药居'
methods: { },
handleTagRemove (name) { {
this['tab' + name] = false; name: '张小刚',
}, age: 25,
addTab(){ address: '北京市海淀区西二旗'
this.tabs.push({label:'标签'+this.tabs.length,content:'标签内容'+this.tabs.length}); },
{
name: '李小红',
age: 30,
address: '上海市浦东新区世纪大道'
},
{
name: '周小伟',
age: 26,
address: '深圳市南山区深南大道'
}
]
} }
} }
} }

View file

@ -32,12 +32,13 @@
import TransferDom from '../../directives/transfer-dom'; import TransferDom from '../../directives/transfer-dom';
import { getScrollBarSize } from '../../utils/assist'; import { getScrollBarSize } from '../../utils/assist';
import Locale from '../../mixins/locale'; import Locale from '../../mixins/locale';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-modal'; const prefixCls = 'ivu-modal';
export default { export default {
name: 'Modal', name: 'Modal',
mixins: [ Locale ], mixins: [ Locale, Emitter ],
components: { Icon, iButton }, components: { Icon, iButton },
directives: { TransferDom }, directives: { TransferDom },
props: { props: {
@ -247,6 +248,7 @@
this.addScrollEffect(); this.addScrollEffect();
} }
} }
this.broadcast('Table', 'on-visible-change', val);
}, },
loading (val) { loading (val) {
if (!val) { if (!val) {

View file

@ -664,6 +664,9 @@
this.fixedHeader(); this.fixedHeader();
this.$nextTick(() => this.ready = true); this.$nextTick(() => this.ready = true);
window.addEventListener('resize', this.handleResize, false); window.addEventListener('resize', this.handleResize, false);
this.$on('on-visible-change', (val) => {
if (val) this.handleResize();
});
}, },
beforeDestroy () { beforeDestroy () {
window.removeEventListener('resize', this.handleResize, false); window.removeEventListener('resize', this.handleResize, false);

View file

@ -23,11 +23,13 @@
<script> <script>
import Icon from '../icon/icon.vue'; import Icon from '../icon/icon.vue';
import { oneOf, getStyle } from '../../utils/assist'; import { oneOf, getStyle } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
const prefixCls = 'ivu-tabs'; const prefixCls = 'ivu-tabs';
export default { export default {
name: 'Tabs', name: 'Tabs',
mixins: [ Emitter ],
components: { Icon }, components: { Icon },
props: { props: {
value: { value: {
@ -226,6 +228,7 @@
activeKey () { activeKey () {
this.updateBar(); this.updateBar();
this.updateStatus(); this.updateStatus();
this.broadcast('Table', 'on-visible-change', true);
} }
}, },
mounted () { mounted () {

View file

@ -168,14 +168,14 @@ export function scrollTop(el, from = 0, to, duration = 500) {
} }
// Find components upward // Find components upward
function findComponentUpward (content, componentName, componentNames) { function findComponentUpward (context, componentName, componentNames) {
if (typeof componentName === 'string') { if (typeof componentName === 'string') {
componentNames = [componentName]; componentNames = [componentName];
} else { } else {
componentNames = componentName; componentNames = componentName;
} }
let parent = content.$parent; let parent = context.$parent;
let name = parent.$options.name; let name = parent.$options.name;
while (parent && (!name || componentNames.indexOf(name) < 0)) { while (parent && (!name || componentNames.indexOf(name) < 0)) {
parent = parent.$parent; parent = parent.$parent;
@ -186,8 +186,8 @@ function findComponentUpward (content, componentName, componentNames) {
export {findComponentUpward}; export {findComponentUpward};
// Find component downward // Find component downward
function findComponentDownward (content, componentName) { function findComponentDownward (context, componentName) {
const childrens = content.$children; const childrens = context.$children;
let children = null; let children = null;
if (childrens.length) { if (childrens.length) {
@ -215,8 +215,8 @@ function findComponentDownward (content, componentName) {
export {findComponentDownward}; export {findComponentDownward};
// Find components downward // Find components downward
function findComponentsDownward (content, componentName, components = []) { function findComponentsDownward (context, componentName, components = []) {
const childrens = content.$children; const childrens = context.$children;
if (childrens.length) { if (childrens.length) {
childrens.forEach(child => { childrens.forEach(child => {