diff --git a/lib/compile-vue.js b/lib/compile-vue.js index 33097c5..3fae656 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -289,7 +289,7 @@ export function compileVue(file, imports, options = {}) { let js = code.match(JS_EXP) let scss = [...code.matchAll(STYLE_EXP)] let html = code.match(HTML_EXP) || ['', ''] - let linePatch = code.slice(0, js.index).split('\n').length // js起始行数修正 + let linePatch = code.slice(0, js?.index || 0).split('\n').length // js起始行数修正 let hash = md5(file) let scopeId = 'data-' + hash