1
0
mirror of https://github.com/sahadev/vue-component-creater-ui.git synced 2026-01-11 15:22:28 +08:00

feat: 支持单文件二次编辑

This commit is contained in:
shangbin
2021-11-16 19:58:28 +08:00
parent 4cde9098bc
commit 2f4b143550
8 changed files with 139 additions and 19 deletions

View File

@@ -0,0 +1,69 @@
<template>
<div class="container" style="min-height: 100%; padding-bottom: 100px;">
<div>
<el-input v-model="code" type="textarea" :rows="4" />
<el-button lc-mark @click="compile">解析</el-button>
</div>
<vcc :initCodeEntity="codeStructure" @updateCodeEntity="onCodeUpdate"></vcc>
</div>
</template>
<script>
import { html2Json } from '../libs/bundle-html2json-esm';
import vcc from '../components-v2/VCC.vue';
import { ergodic } from '../utils/common';
function findAObject(array, propertyName) {
const module = array.find(function (ele) {
return ele[propertyName];
});
return module || null;
}
export default {
props: [],
components: {
vcc,
},
data: () => {
return {
code: '',
codeStructure: ""
}
},
watch: {},
computed: {},
beforeCreate: () => { },
created: () => { },
beforeMount: () => { },
mounted: async () => {
},
beforeUpdate: () => { },
updated: () => { },
destoryed: () => { },
methods: {
async compile() {
const obj = await html2Json(this.code);
const template = findAObject(obj.root.__children, 'template');
ergodic(template);
this.codeStructure = template;
},
onCodeUpdate(newCodeEntity) {
// 编辑后新的代码结构
}
},
fillter: {},
}
</script>
<style scoped>
.container {
}
</style>