起因:我用了百度Ueditor插件在vue里,目的是生成H5页面,所以我只Ueditor获取了html片段,为的是自己添加html的头部和尾部;
1.vue data操作
header:'<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><style type="text/css">html,body {height: 100%;width: calc(100% - 10px);padding: 0;margin: 0;}</style><style type="text/css">img{height: auto !important;width:100% !important;};</style><style type="text/css">#content {width: 90%;height: 100%;padding: 0;margin: 10px auto;};</style></head><body>',
footer:'</body></html>'
//Ueditor获取的片段例子
content='<section><>123</section>'
//合并成完整的html
html = header + content + footer;
我把这三部分拼接成了完整的html存到了后台;
2.vue变量写法没报错,生成H5页报错
vue变量写法没报错,换成html页面写法就错了
let header='<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><style type="text/css">html,body {height: 100%;width: calc(100% - 10px);padding: 0;margin: 0;}</style><style type="text/css">img{height: auto !important;width:100% !important;};</style><style type="text/css">#content {width: 90%;height: 100%;padding: 0;margin: 10px auto;};</style></head><body>';
let footer='</body></html>' //报错了此处
在html页面let footer='</body></html>' 片段报错了此处~~~~
请各位帮看看怎么写才不会报错呢,感谢~~~
附上报错码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body>
<div id="content">12343</div>
<script type="text/javascript">
let footer='</body></html>'
</script>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…