Open Yan2603 opened 2 years ago
默认情况下cheerio.load会返回有html head body的节点,能否支持一下配置可以去掉,在vue-router场景会影响DOM的默认结构
cheerio.load
html
head
body
/** * html => vue file template * @param {[type]} html [description] * @return {[type]} [description] */ var renderVueTemplate = function(html, wrapper) { var $ = cheerio.load(html, { decodeEntities: false, lowerCaseAttributeNames: false, lowerCaseTags: false }); var output = { style: $.html('style'), // get only the first script child. Causes issues if multiple script files in page. script: $.html($('script').first()) }; var result; $('style').remove(); $('script').remove(); result = `<template><${wrapper}>` + $.html() + `</${wrapper}></template>\n` + output.style + '\n' + output.script; return result; };
默认情况下
cheerio.load
会返回有html
head
body
的节点,能否支持一下配置可以去掉,在vue-router场景会影响DOM的默认结构