Replies: 2 comments
-
Fullscreen组件优化方案: 普通全屏充满当前浏览器窗口的普通全屏。 <template>
<d-fullscreen v-model="isOpen">
<div>
<d-button @click="isOpen = !isOpen">{{btnContent}}</d-button>
</div>
</d-fullscreen>
</template>
<script>
import { ref, watch } from 'vue'
export default {
setup() {
const isOpen = ref(false)
const btnContent = ref('全屏')
watch(isOpen, (newVal) => {
if (newVal) {
btnContent.value = '退出全屏'
} else {
btnContent.value = '全屏'
}
})
return {
btnContent,
isOpen,
}
}
}
</script> 沉浸式全屏充满整个显示器屏幕的沉浸式全屏。 <template>
<d-fullscreen v-model="isOpen" mode="immersive">
<div>
<d-button @click="isOpen = !isOpen">{{btnContent}}</d-button>
</div>
</d-fullscreen>
</template>
<script>
import { ref, watch } from 'vue'
export default {
setup() {
const isOpen = ref(false)
const btnContent = ref('全屏')
watch(isOpen, (newVal) => {
if (newVal) {
btnContent.value = '退出全屏'
} else {
btnContent.value = '全屏'
}
})
return {
btnContent,
isOpen,
}
}
}
</script> 参数及API
|
Beta Was this translation helpful? Give feedback.
0 replies
-
已优化 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
api
Fullscreen组件:https://vue-devui.github.io/components/fullscreen/
Fullscreen
组件目前的设计是通过fullscreen-target
和fullscreen-launch
两个属性选择器来区分:fullscreen-target
- 触发全屏的目标按钮fullscreen-launch
- 需要全屏的元素并且这两个元素必须包裹在
<d-fullscreen>
组件里面。这样不太合理,使用起来很别扭,建议用以下方式实现全屏组件:
<d-fullscreen>
组件只承载需要全屏的元素,它里面包裹的元素就是需要全屏的元素<d-fullscreen>
组件设置一个isOpen
属性,用来设置全屏的开启与关闭,这样就可以通过外部控制全屏fullscreenLaunch
也可以废弃了<d-fullscreen>
组件增加一个onClose
关闭全屏的回调函数,退出全屏的时候会触发这个回调函数使用方式大致如下:
Beta Was this translation helpful? Give feedback.
All reactions