鍍金池/ 問答/HTML/ vue script methods方法中如何引用css文件

vue script methods方法中如何引用css文件

獲取文件夾下的css文件到download方法中,這個如何引入進來 ,我會拼接到html變量中,下載文件操作!

methods:{
        download(){            
            const template = this.$refs.resume.$el.innerHTML;            
            let html = `<!DOCTYPE html>
                        <html>
                        <head>
                            <meta charset="utf-8">
                            <meta name="viewport" content="width=device-width,initial-scale=1.0">
                            <title>X-Find迅聘選才</title>
                            <style>
                            </style>
                        </head>
                        <body>
                            <div class="resume_preview_page" style="margin:0 auto;width:1200px">
                            ${template}
                            </div>
                        </body>
                        </html>`
            writer('test.html', html, 'utf-8')
        }
    }
回答
編輯回答
舊酒館

你可能需要一個這個 css 的絕對路徑,然后在 html 的 head 里面 link 引入 =。=

2017年9月22日 19:56
編輯回答
冷溫柔

你用的writer是不是我寫的file-writer?

你的這個問題其實就是想說,我這里文件夾下有一個css,怎么搞成字符串吧?

如果是的話可以使用:

// 下面的代碼將css文件內(nèi)容打印出來
const url = '' // 你的css的可以訪問的路徑,比如CDN路徑
fetch(url).then(res => res.text()).then(console.log)
2017年11月1日 22:42