vue使用screenfull插件實現(xiàn)全屏功能
本文實例為大家分享了vue使用screenfull插件實現(xiàn)全屏功能的具體代碼,供大家參考,具體內(nèi)容如下
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' :src='http://m.baoyu77737.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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Java:過去、未來的互聯(lián)網(wǎng)編程之王2. Python中scrapy下載保存圖片的示例3. vue實現(xiàn)點擊按鈕切換背景顏色的示例代碼4. python 爬取豆瓣網(wǎng)頁的示例5. Android自定義控件之圓形進(jìn)度條動畫6. php 輸出緩沖 Output Control用法實例詳解7. 使用EF Code First搭建簡易ASP.NET MVC網(wǎng)站并允許數(shù)據(jù)庫遷移8. 創(chuàng)建Android守護(hù)進(jìn)程實例(底層服務(wù))9. Python中實現(xiàn)輸入一個整數(shù)的案例10. 解決Vue 移動端點擊出現(xiàn)300毫秒延遲的問題
