export default class HController {
//路由
Url('/index/index')
//渲染模板
Render("home/index.html")
//调用函数
index(){
//这里需要跨域获取值,
(async function () {
const fetch = require('node-fetch');
const res = await fetch('http://www.xxx.com/shop/index.php');
const json = await res.json();
//获取的值可以拿到外面使用,其他方法可以实现跨域获取,并能赋给全局变量也可
})();
}
}
我该怎么写,才能把json变量的值拿到函数外面使用?