vue使用screenfull插件實現(xiàn)全屏功能
更新時間:2020年09月17日 09:50:17 作者:lt要努力
這篇文章主要為大家詳細介紹了vue使用screenfull插件實現(xiàn)全屏功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue使用screenfull插件實現(xiàn)全屏功能的具體代碼,供大家參考,具體內容如下
1、安裝screenfull.js插件(在npm官網(wǎng)上有)
npm install screenfull --save
2、在vue項目中 src/components/ScreenFull/index.vue(寫成公共組件)
<template>
<el-tooltip effect="dark" content="全屏" placement="bottom">
<img @click="screen" class="pointer" :src="require('@/assets/images/screenful.png')" :width="width" :height="height">
</el-tooltip>
</template>
<script>
import screenfull from 'screenfull'
export default {
name: 'screenful',
components: {
},
props: {
width: {
type: Number,
default: 20
},
height: {
type: Number,
default: 20
}
},
data() {
return {
}
},
computed: {
},
watch: {
},
methods: {
screen() {
if (!screenfull.isEnabled) {
this.$message({
message: 'you browser can not work',
type: 'warning'
})
return false
}
screenfull.toggle()
}
},
created() {
},
mounted() {
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
</style>
3、使用screenful組件
<template>
<screenfull class="ml64" :width="20" :height="20"></screenfull>
</template>
<script>
import screenfull from '@/components/ScreenFull'
export default {
name: 'navbar',
components: {
screenfull
},
data() {
return {
}
},
computed: {
},
watch: {
},
methods: {
},
created() {
},
mounted() {
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
</style>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
vue excel上傳預覽和table內容下載到excel文件中
這篇文章主要介紹了vue excel上傳預覽和table內容下載到excel文件中,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-12-12
vue-router beforeEach跳轉路由驗證用戶登錄狀態(tài)
這篇文章主要介紹了vue-router beforeEach跳轉路由驗證用戶登錄狀態(tài),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12
Vue2+Element-ui實現(xiàn)el-table表格自適應高度的案例
這篇文章主要介紹了Vue2+Element-ui實現(xiàn)el-table表格自適應高度的案例,本文結合示例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧2024-06-06

