javascript - 'require'未定义VS代码
问题描述
我是 VS Code 的新手。正如标题所示,我试图要求各种 SDK 让我的 JEE 正常运行。当我尝试上线时,控制台会吐出这个错误:
Uncaught ReferenceError: require is not defined
at fbaccess.js:10
我记得在我使用 Android 开发的日子里,我们总是有一个清单文件来要求东西,但我不确定如何在 VS Code 中全局导入/正确调用东西。
这是应该调用一些示例数据的 fbaccess.js 代码(在 node.js 中输出:
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
* @flow
*/
const bizSdk = require('facebook-nodejs-business-sdk');
const AdAccount = bizSdk.AdAccount;
const AdsInsights = bizSdk.AdsInsights;
let access_token = '****';
let ad_account_id = '****';
let app_secret = '****';
let app_id = '****';
const api = bizSdk.FacebookAdsApi.init(access_token);
const account = new AdAccount(ad_account_id);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
api.setDebug(true);
}
let ads_insights;
let ads_insights_id;
const logApiCallResult = (apiCallName, data) => {
console.log(apiCallName);
if (showDebugingInfo) {
console.log('Data:' + JSON.stringify(data));
}
};
const fields = [
'results',
'impressions',
'spend',
'quality_score_organic',
];
const params = {
'level' : 'campaign',
'filtering' : [],
'breakdowns' : [],
'time_range' : {'since':'2019-10-09','until':'2019-10-09'},
};
(new AdAccount(ad_account_id)).getInsights(
fields,
params
).then((result) => {
logApiCallResult('ads_insights api call complete.', result);
ads_insights_id = result[0].id;
})
.catch((error) => {
console.log(error);
});
任何帮助,将不胜感激!
解决方案
将此添加到头部的 html 中。
<script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
<script type="text/javascript" src="https://unpkg.com/web3@0.20.5/dist/web3.min.js"></script>
推荐阅读
- toml - 数组内的 TOML 多级表语法——非法与否
- javascript - 如何在 React 中制作元素过滤器?
- javascript - 通用与特定 API 响应
- c# - 在 ASP.Net Core 2.2 中播种 MongoDB 的最佳方法是什么
- matlab - 使用 parfeval() 时的 Matlab-GUI 警告:“无法保存 App Designer 应用程序对象。”
- spacy - 是否可以获得 IOB 格式的预测?- NER
- c++ - 带有范围滑块的 OpenCV HSV 过滤器不起作用
- laravel - [Vue 警告]:挂载钩子错误:“ReferenceError: google 未定义
- java - 使用 java 8 流 api 做数组列表的深拷贝,但得到构建时间错误
- flask - Flask 模板中的表单状态丢失