fix: expand $scopedSlots to avoid not rerendering

This commit is contained in:
07akioni 2019-12-23 20:58:36 +08:00
parent 78186876e1
commit 5ee7ba1906
11 changed files with 32 additions and 51 deletions

View File

@ -1,7 +1,7 @@
<template>
<div>
<n-button @click="isActive = true">active</n-button>
<modal-wrapper :is-active="isActive"/>
<modal-wrapper v-model="isActive"/>
</div>
</template>

View File

@ -1,56 +1,28 @@
<template>
<n-modal v-model="isActive">
<n-nimbus-form-card
width="1032"
title="Parklife"
:deactivate="() => isActive = false"
>
<template v-slot:header>
{{ time }}
</template>
<template v-slot:footer>
v-slot:footer
</template>
<template v-slot:content>
<n-input
v-model="time"
/>
<n-select
v-model="selectedValue"
size="small"
placeholder="Please Select Type"
:items="items"
style="flex-grow: 1;"
/>
<n-tooltip
placement="bottom"
trigger="click"
style="margin-right: 12px;"
>
<template v-slot:activator>
<n-button style="margin: 0;">
California Girls(Click)
</n-button>
</template>
<span>
I wish they all could be California girls
</span>
</n-tooltip>
</template>
</n-nimbus-form-card>
<n-modal v-model="value">
<template v-slot:header>
<n-input v-model="time" /> {{ time }}
<n-button>Look at it</n-button>
</template>
<n-input v-model="time" /> {{ time }}
<template v-slot:footer>
<n-input v-model="time" /> {{ time }}
<n-button>Look at it</n-button>
</template>
</n-modal>
</template>
<script>
export default {
props: {
isActive: {
value: {
type: Boolean,
default: false
}
},
data () {
return {
time: null,
isActive: false,
time: '666',
selectedValue: null,
items: [
{

View File

@ -1,5 +1,5 @@
<template>
<modal :is-active="isActive"/>
<modal v-model="value"/>
</template>
<script>
@ -10,7 +10,7 @@ export default {
modal
},
props: {
isActive: {
value: {
type: Boolean,
default: false
}

View File

@ -54,6 +54,8 @@ import asthemecontext from '../../../mixins/asthemecontext'
import NIcon from '../../../common/Icon'
import mdClose from '../../../icons/md-close'
window.cardSlots = []
export default {
name: 'NCard',
components: {

View File

@ -31,7 +31,7 @@ export default {
label: this.$scopedSlots.default ? '' : (this.label || this.name),
value: this.value
},
scopedSlots: this.$scopedSlots,
scopedSlots: { ...this.$scopedSlots },
on: {
...this.$listeners,
click: (...args) => {

View File

@ -174,7 +174,7 @@ export default {
},
render (h) {
const options = h(WrapWithValue, {
scopedSlots: this.$scopedSlots
scopedSlots: { ...this.$scopedSlots }
})
return h('div', {
staticClass: 'n-dropdown-menu',

View File

@ -23,7 +23,7 @@ export default {
return h(NFormItem, {
ref: 'formItem',
props: { ...this.$props },
scopedSlots: this.$scopedSlots
scopedSlots: { ...this.$scopedSlots }
})
}
}

View File

@ -26,7 +26,7 @@ export default {
span: 24,
...this.$props
},
scopedSlots: this.$scopedSlots
scopedSlots: { ...this.$scopedSlots }
})
}
})

View File

@ -146,7 +146,7 @@ export default {
}
}
},
scopedSlots: this.$scopedSlots
scopedSlots: { ...this.$scopedSlots }
}
)
])

View File

@ -45,7 +45,7 @@
</template>
</n-confirm>
<n-card
v-if="preset === 'card'"
v-else-if="preset === 'card'"
:style="bodyStyle"
:title="title"
:closable="closable"
@ -128,6 +128,13 @@ export default {
this.styleActive = true
}
},
updated () {
this.$nextTick().then(() => {
console.log('modal rerender')
console.log(this.$slots.default[1].text)
console.log(this.$scopedSlots.default()[1].text)
})
},
methods: {
slotDOM () {
const els = (this.$refs.contentInner && this.$refs.contentInner.childNodes) || []

View File

@ -114,7 +114,7 @@ export default {
return h(NSelect, {
props: { ...this.$props, options: this.computedOptions, active: this.active, placement: 'bottom-start', widthMode: 'activator', useSlot: !!this.$scopedSlots.default },
on,
scopedSlots: this.$scopedSlots
scopedSlots: { ...this.$scopedSlots }
})
}
}