Skip to content

Commit

Permalink
fix: transition cannt work
Browse files Browse the repository at this point in the history
  • Loading branch information
wuls committed Nov 20, 2020
1 parent 0d3e5b1 commit a18489d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/docs/zh-CN/tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
})
const saveTagInput = ref(null)
const handleClose = (tag) => {
state.dynamicTags.splice(state.dynamicTags.indexOf(tag), 1)
// state.dynamicTags.splice(state.dynamicTags.indexOf(tag), 1)
}
const showInput = () => {
state.inputVisible = true
Expand Down
2 changes: 1 addition & 1 deletion examples/versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","0.0.24":"2.13"}
{"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","0.0.25":"2.13"}
38 changes: 38 additions & 0 deletions packages/menu/__tests__/Menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import Submenu from '../Submenu.vue'
import MenuItemGroup from '../MenuItemGroup.vue'
import { mount } from '@vue/test-utils'
import { nextTick } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
const Home = { template: '<div>Home</div>' }
const About = { template: '<div>About</div>' }
const routes = [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
const router = createRouter({
// 4. Provide the history implementation to use. We are using the hash history for simplicity here.
history: createWebHistory(),
routes // short for `routes: routes`
})

const components = {
ElMenu: Menu,
Expand Down Expand Up @@ -411,5 +423,31 @@ describe('Menu.vue', () => {
await wrapper.setProps({ defaultActive: '3' })
expect(wrapper.find('.el-menu-item.is-active').text()).toContain('year')
})
it('mode is route', async () => {
const C = {
template: `
<el-menu router>
<el-menu-item index="/">处理中心</el-menu-item>
<el-menu-item index="/about">消息中心</el-menu-item>
</el-menu>
<div class="example">
<router-view />
</div>
`,
components
}
router.push('/')
await router.isReady()
const wrapper = mount(C, {
global: {
plugins: [router]
}
})
await wrapper.find('.el-menu-item').trigger('click')
expect(wrapper.find('.example').html()).toContain(
'<div class="example"><div>Home</div></div>'
)
})
})
})
8 changes: 6 additions & 2 deletions packages/tag/Tag.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="jsx">
import { computed, getCurrentInstance, Transition } from 'vue'
import { computed, getCurrentInstance, Transition, reactive } from 'vue'
export default {
name: 'ElTag',
props: {
Expand All @@ -20,11 +20,13 @@ export default {
},
emits: ['close', 'click'],
setup(props, { emit, slots }) {
const state = reactive({ show: true })
const tagSize = computed(() => {
return props.size || (getCurrentInstance().proxy.$ELEMENT || {}).size
})
const handleClose = (event) => {
event.stopPropagation()
state.show = false
emit('close', event)
}
const handleClick = (event) => {
Expand Down Expand Up @@ -53,7 +55,9 @@ export default {
return props.disableTransitions ? (
tagEl
) : (
<Transition name="el-zoom-in-center">{tagEl}</Transition>
<Transition name="el-zoom-in-center">
{state.show ? tagEl : ''}
</Transition>
)
}
}
Expand Down

0 comments on commit a18489d

Please sign in to comment.