FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

How to use scss as style language #184

Closed Julyzl closed 2 months ago

Julyzl commented 3 months ago

it's my example,But it didn't work,Can the author write an example,thanks! import sassloader from 'sass-loader' options: { moduleCache: { vue: Vue, dayjs: dayjs, scss: (source) => Object.assign(sass(source), { deps: () => [] }) // (source) => Object.assign(sass(source), { deps: () => [] }) }, // 获取文件 async getFile(url: any) { const res = await fetch(url) if (!res.ok) throw Object.assign(new Error(url + ' ' + res.statusText), { res }) return await res.text() }, // 添加样式 addStyle(textContent: any) { const style = Object.assign(document.createElement('style'), { textContent }) const ref = document.head.getElementsByTagName('style')[0] || null document.head.insertBefore(style, ref) } }

mustapha-wang commented 3 months ago

what is wrong?错误信息是啥?

Julyzl commented 3 months ago

报错信息: vue3-sfc-loader.js?v=4c92af84:24805 Uncaught (in promise) TypeError: Unable to handle files (scss)

Julyzl commented 3 months ago

微信图片_20240321135557 这是我的示例,这样写scss就不会报Unable to handle files (scss)这个错了

Julyzl commented 3 months ago

但是写lang=scss 没有效果,就像好像没写样式一样 你那边有示例吗?