是否有任何库或机会来置换标签内的代码? 事实上,我的想法是下一步:将Vue.js与Google Apps脚本一起使用。
/* This script is deployed as a web app */
function doGet(e) {
try {
var templateName = 'index';
var data = {
text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
};
return getTemplateWithData(templateName, data);
} catch (err) {
Logger.log(err.toString());
}
}
/* Wrapper to return a html template with data */
function getTemplateWithData(htmlFileName, data) {
var template = HtmlService.createTemplateFromFile(htmlFileName);
template.data = data;
return template.evaluate();
}
function include(filename) {
return HtmlService.createTemplateFromFile(filename).evaluate().getContent();
}
//In index.html:
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
....
<body>
<?!= include('templates'); ?>
<?!= include('Components.js'); ?>
</body>
//In templates.html:
<!-- "app" (root instance) template -->
<template id="app-template" hidden v-cloak>
<div class="app"><h1>Hello World!</h1></div>
</template>
//In Components.js.html:
<script>
/* The Root instance (Renderer) */
var app = new Vue({
el: '#app',
template: '#app-template',
})
</script>
如果我使用VUE CLI,我将看不到每个组件的任何html模板,并且所有javascript代码都将被缩小并且(已经过时?)
我的问题是关于...在使用Google Apps脚本进行代码预处理之前,因为Vue组件在源代码和所有脚本中都可见...