H5-contact/node_modules/@dcloudio/uni-h5-vite/dist/utils/polyfill.js

22 lines
884 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rewriteCompilerSfcParse = void 0;
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
/**
* 重写 @vue/compiler-sfc 的 parse 函数
* web 平台下,如果 SFC 没有 style注入一个默认的空 style
*/
function rewriteCompilerSfcParse() {
const compilerSfc = require((0, uni_cli_shared_1.resolveBuiltIn)('@vue/compiler-sfc'));
const { parse } = compilerSfc;
compilerSfc.parse = (source, options) => {
const result = parse(source, options);
// 如果没有 style注入一个默认的空 style
if (result.descriptor.styles.length === 0) {
result.descriptor.styles = [(0, uni_cli_shared_1.createDefaultSFCStyleBlock)(source)];
}
return result;
};
}
exports.rewriteCompilerSfcParse = rewriteCompilerSfcParse;