vue使用screenfull插件實(shí)現(xiàn)全屏功能
本文實(shí)例為大家分享了vue使用screenfull插件實(shí)現(xiàn)全屏功能的具體代碼,供大家參考,具體內(nèi)容如下
1、安裝screenfull.js插件(在npm官網(wǎng)上有)
npm install screenfull --save
2、在vue項(xiàng)目中 src/components/ScreenFull/index.vue(寫成公共組件)
<template> <el-tooltip effect='dark' content='全屏' placement='bottom'> <img @click='screen' :src='http://www.cgvv.com.cn/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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. vue跳轉(zhuǎn)頁(yè)面常用的幾種方法匯總2. XML 非法字符(轉(zhuǎn)義字符)3. CSS3實(shí)例分享之多重背景的實(shí)現(xiàn)(Multiple backgrounds)4. XML入門的常見問(wèn)題(三)5. 不要在HTML中濫用div6. ASP動(dòng)態(tài)include文件7. 父div高度不能自適應(yīng)子div高度的解決方案8. asp createTextFile生成文本文件支持utf89. Jquery使用原生AJAX方法請(qǐng)求數(shù)據(jù)10. el-input無(wú)法輸入的問(wèn)題和表單驗(yàn)證失敗問(wèn)題解決
