Former-commit-id: dcd478f08f3aa372ddd6013866b8263f7cc9b059
Former-commit-id: e6bfe9d4e9931883cc4b67301c658222f5787285
1.0
wanggang 4 years ago
parent 74a45b29d2
commit d0810953dc

@ -26,6 +26,9 @@
<script>
({
props: ['device'],
mounted: function () {
this.setStyle;
},
computed: {
status: function () {
return getIoTDataValue(this.device, '光照度');
@ -41,4 +44,9 @@
}
}
});
</script>
</script>
<style>
[component] span {
color:blue;
}
</style>

@ -11,16 +11,22 @@ function copy(from, to) {
//eval解析vue组件
function parseModel(response) {
var html = new DOMParser().parseFromString(response.data, 'text/html');
var template = html.getElementsByTagName('template')[0].innerHTML;
var template = html.getElementsByTagName('template')[0];
var script = html.getElementsByTagName('script')[0].innerHTML;
script = '(' + script.replace(/^\s*export\s*default\s*/, '').replace(/;?\s*$/, '') + ')\n//# sourceURL=' + response.config.url;
var model = eval(script);
if (model) {
model.template = template;
}
else {
console.error('eval error');
var model = eval(script) || {};
if (html.getElementsByTagName('style').length > 0) {
var hash = response.config.url;
var style = html.getElementsByTagName('style')[0];
style.setAttribute('data-vue-style', hash);
var styleValue = style.outerHTML.replace('[component]', "[data-vue-style='" + hash + "']");
if ($("style[data-vue-style='" + hash + "']").length === 0) {
$('head').append(styleValue);
}
template.content.children[0].setAttribute('data-vue-style', hash);
model.template = template.outerHTML;
}
model.template = template;
return model;
}
//循环添加vue组件

@ -1,4 +1,22 @@
const app = new Vue({
const { loadModule, vueVersion } = window['vue2-sfc-loader'];
const options = {
moduleCache: {
vue: Vue,
myData: {
vueVersion,
}
},
getFile(url) {
console.log(url);
},
addStyle() {
const style = Object.assign(document.createElement('style'), { textContent });
const ref = document.head.getElementsByTagName('style')[0] || null;
document.head.insertBefore(style, ref);
}
}
const app = new Vue({
el: '#app',
router,
store: store,

Loading…
Cancel
Save