// 引入 Vue 和 VueComponent

export default{
   data() {
    return {
    
    }
   },
   mounted() {

    },
    methods: {
        async getComponents(path){
            var params = {
                template:''
            }
            await fetch(`./reportTemplate/${path}/${path}.txt`).then(res => {
                return res.text()
            }).then(data => {
                    if(data.indexOf('<!DOCTYPE html>') == -1){
                        this.getCss(path)
                        params.template = data
                    }
                    
            })
            return params
        },
        getCss(path){
            const url = `./reportTemplate/${path}/${path}.css`
            const linkId = `#reportTemplate${path}`
            const model = document.getElementById(linkId)
            if(path != undefined){
                if(model == null){
                    const link = document.createElement('link')
                    link.rel = 'stylesheet'
                    link.href = url
                    link.id = linkId
                    document.head.appendChild(link)
                }else{
                    // model.setAttribute('href',url)
                    model.remove()
                }
            }else if(model != null){
                model.remove()
            }
        }
    },
}
 
