mirror of
https://github.com/sahadev/vue-component-creater-ui.git
synced 2025-06-07 13:44:06 +08:00
验证转发接口
This commit is contained in:
parent
cc20787843
commit
c5d834664c
@ -52,11 +52,12 @@ import 'codemirror/addon/fold/markdown-fold.js'
|
||||
import 'codemirror/addon/fold/xml-fold.js'
|
||||
|
||||
require(['axios'], axios => {
|
||||
axios.defaults.baseURL = '';
|
||||
self.axios = axios;
|
||||
self.axios = axios.create({
|
||||
baseURL: '',
|
||||
timeout: 1000,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
export default {
|
||||
name: 'code-editor',
|
||||
title: 'Mode: text/x-vue & Theme: monokai',
|
||||
@ -69,6 +70,7 @@ export default {
|
||||
/**
|
||||
* 以下代码中的方法会被注入到最终的代码中,如果命名与源代码有相同的,则会替换源代码
|
||||
* 内部集成了axios,开发者可以直接通过axios发起网络请求,不过接口需要允许跨域。
|
||||
* 通过http://69.234.242.21:3000/exchange?url=的方式访问实际地址可以解决跨域问题。
|
||||
* axios官方文档:https://www.npmjs.com/package/axios
|
||||
*/
|
||||
{
|
||||
@ -90,7 +92,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
request(){
|
||||
axios.get('https://www.baidu.com').then(res => console.info(res), err => console.error(err));
|
||||
axios.get('http://69.234.242.21:3000/exchange?url=https://www.baidu.com').then(res => console.info(res), err => console.error(err));
|
||||
}
|
||||
},
|
||||
|
||||
@ -142,7 +144,7 @@ export default {
|
||||
onCmBlur(codemirror) {
|
||||
},
|
||||
|
||||
getEditorCode(){
|
||||
getEditorCode() {
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,10 @@ export class MainPanelProvider {
|
||||
|
||||
const { template, script, styles, customBlocks } = parseComponent(code);
|
||||
|
||||
let newScript = script.content.replace("export default", "")
|
||||
newScript = newScript.replace(/\s+/g, "");
|
||||
let newScript = script.content.replace(/\s*export default\s*/, "")
|
||||
|
||||
// 将xxx: () => {} 转换为xxx(){}
|
||||
newScript = newScript.replace(/:\s*\(([\w\s]*)\)\s*=>/g,"\($1\)");
|
||||
|
||||
const componentOptions = (new Function(`return ${newScript}`))();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user