typescript沒法識別vue中的$refs

例如:vue-fullscreenvue

<template>
    <div class="Test">
        <fullscreen ref="fullscreen" @change="fullscreenChange" >
       <el-button @click="toggle">全屏</el-button>
            something
        </fullscreen>
    </div>
</template>

<script lang="ts">
    import { Vue, Component, Prop, Watch } from 'vue-property-decorator';// @ts-ignore
    import fullscreen from 'vue-fullscreen';
    Vue.use(fullscreen);

    @Component({})
    export default class Test extends Vue {
        toggle() {
            (this.$refs.fullscreen as fullscreen).toggle(); // !!!! as後面的fullscreen是引入後組件的名稱
        }

        fullscreenChange(status: boolean) {
            this.fullscreen = status;
        }
    }
</script>

<style lang="less" scoped>
    .Test{}
</style>
相關文章
相關標籤/搜索