1
0
mirror of https://github.com/sahadev/vue-component-creater-ui.git synced 2025-06-07 21:54:05 +08:00

支持解析注释

This commit is contained in:
shangbin 2021-09-14 10:52:35 +08:00
parent d4e5621743
commit fee37b267a
2 changed files with 7 additions and 8 deletions

View File

@ -66,6 +66,11 @@ export default {
data() {
return {
code: dedent`
/**
* 以下代码中的方法会被注入到最终的代码中如果命名与源代码有相同的则会替换源代码
* 内部集成了axios开发者可以直接通过axios发起网络请求不过接口需要允许跨域
* axios官方文档https://www.npmjs.com/package/axios
*/
{
props: [],
components: {},

View File

@ -1,13 +1,6 @@
<template>
<el-dialog title="JS逻辑编辑" :visible.sync="codeDialogVisible" width="70%" top="10vh" :before-close="handleClose"
:center=true>
<div style="font-size:12px; margin-top:5px;">
// </div>
<div style="font-size:12px; margin-top:5px;">
// axiosaxios</div>
<div style="font-size:12px; margin-top:5px;">
// axioshttps://www.npmjs.com/package/axios</div>
<CodeEditor ref="codeEditor"></CodeEditor>
<div style="text-align:center;padding: 10px;">
@ -49,7 +42,8 @@ export default {
},
onSave() {
const code = this.$refs.codeEditor.getEditorCode();
const JSCodeInfo = eval(`(function(){return ${code}})()`);
const temp = code.replace(/.+\*\/\s*/gs, "");
const JSCodeInfo = eval(`(function(){return ${temp}})()`);
console.info(JSCodeInfo.methods.request.toString());
}
},