<template>
    <div class="need-know" :id="'need-know_' + keyname" v-if="detail">
        <!-- <h2>{{detail.titleZh}}</h2> -->
        <div class="body" v-html="detail.contentZh"></div>
    </div>
</template>
<script>
import {getNeedKnowByKey} from '@/api/system/needKnow'
import html2canvas from 'html2canvas'
import FileSaver from 'file-saver'
export default {
    props:{
        keyname: String
    },
    data(){
        return {
            detail: null
        }
    },
    created(){
        getNeedKnowByKey(this.keyname).then(res => {
            this.detail = res.data
        })
    },
    methods:{
        download(){
            // 直接保存图片
            let l = this.$loading()
            html2canvas(document.querySelector("#need-know_" + this.keyname)).then(canvas => {
                canvas.toBlob((blob) => {
                    FileSaver.saveAs(blob, this.keyname + '.png')
                })
            }).finally(res => {
                l.close()
            });
        },
    }
}
</script>
<style scoped>
.body img{
    max-width: 100%;
}
.need-know{
    padding: 20px;
}
</style>