vue使用screenfull插件實現全屏功能
本文實例為大家分享了vue使用screenfull插件實現全屏功能的具體代碼,供大家參考,具體內容如下
1、安裝screenfull.js插件(在npm官網上有)
npm install screenfull --save
2、在vue項目中 src/components/ScreenFull/index.vue(寫成公共組件)
<template> <el-tooltip effect='dark' content='全屏' placement='bottom'> <img @click='screen' :src='http://www.piao2010.com/bcjs/require(’@/assets/images/screenful.png’)' : :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 : :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>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章:
1. ThinkPHP5 通過ajax插入圖片并實時顯示(完整代碼)2. IntelliJ IDEA設置條件斷點的方法步驟3. Java構建JDBC應用程序的實例操作4. Express 框架中使用 EJS 模板引擎并結合 silly-datetime 庫進行日期格式化的實現方法5. Python使用oslo.vmware管理ESXI虛擬機的示例參考6. IDEA EasyCode 一鍵幫你生成所需代碼7. 一篇文章帶你了解JavaScript-對象8. javascript設計模式 ? 建造者模式原理與應用實例分析9. python flask框架快速入門10. 解決Python paramiko 模塊遠程執行ssh 命令 nohup 不生效的問題
