异常:thirdScriptError totalCost is not defined;at api request success callback function ReferenceError

微信小程序开发 错误修改方法笔记 1  微信小程序中调用豆瓣API接口时提示错误 GET http://api.douban.com/v2/movie/in_theaters 400 的解决方法如下 loadMovie:function(){ var page=this; wx.request({ url: 'http://api.douban.com/v2/movie/in_theaters', / 阅读详情

异常提示

VM789:1 thirdScriptError
totalCost is not defined;at api request success callback function
ReferenceError: totalCost is not defined
    at success (http://127.0.0.1:12446/appservice/pages/home/home.js:92:25)
    at Function.o.(anonymous function) (http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:1296511)
    at http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:125690
    at k (http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:526119)
    at i.<anonymous> (http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:832038)
    at i.emit (http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:574350)
    at Xi (http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:832676)
    at http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:833896
    at http://127.0.0.1:12446/appservice/__dev__/WAService.js:1:597101
    at n (http://127.0.0.1:12446/appservice/__dev__/asdebug.js:1:3175)

出现场景及部分相关代码

getUserInfo: function (e) {
    **********
    **********
    success:function(res){
        if(res.data.message == "success"){
          console.log("调用homeAction/getTotalCostAndCalories成功,且获取数据成功");
          this.setData({
            totalCost : res.data.totalCost,
            calories : res.data.calories
          })
          
        }
        if(res.data.message == "fail"){
          console.log("调用homeAction/getTotalCostAndCalories成功,获取数据失败");
        }
      }
    **********
    **********

从后台(Java)向前台(微信小程序home.js)返回两个值(totalCost,calories )。
在将这两个值分别赋值给页面参数(totalCost,calories )的时候,出现如上错误。

分析原因

根据提示,应该是与回调函数callback 有关。
网上的说法:作用域问题——回调函数中的作用域已经脱离了调用函数了,因此需要在回调函数外边把this赋给一个新的变量才可以了。

参考:
  1. 微信小程序Cannot read property ‘setData’ of null;
  2. 逍遥云天微信小程序开发——使用回调函数出现异常:TypeError: Cannot read property ‘setData’ of undefined

解决方法

```javascript
getUserInfo: function (e) {
	**var myThis = this;**
    **********
    **********
    success:function(res){
        if(res.data.message == "success"){
          console.log("调用homeAction/getTotalCostAndCalories成功,且获取数据成功");
          **myThis**.setData({
            totalCost : res.data.totalCost,
            calories : res.data.calories
          })
          
        }
        if(res.data.message == "fail"){
          console.log("调用homeAction/getTotalCostAndCalories成功,获取数据失败");
        }
      }
    **********
    **********

以上。

在线机器学习(OML-AD)应对时序数据概念漂移的异常检测实战 时序数据异常检测是监控系统健康、识别业务风险的核心技术。其基本原理是通过预测模型学习数据的正常模式,并将预测误差作为异常判定的依据。然而,当数据背后的统计规律随时间发生变化,即发生概念漂移时,传统的静态模型会失效,导致误报和漏报激增。在线机器学习技术通过增量学习,使模型能够随每个新数据点实时微调,为预测式异常检测提供了动态适应能力,从而在数据流持续演化的场景下保持检测的鲁棒性。这种将预测与检测无缝衔接的OML-AD框架,尤其适用于工业监控、金融风控等对实时性与资源效率要求高的领域,有效解决了概念漂移这一核心 阅读详情

相关推荐

告别迷茫!新手如何从RTKLIB命令行程序入手,快速理解GNSS解算全流程

本文为GNSS新手提供RTKLIB命令行程序实战指南,重点介绍如何通过`rnx2rtkp`后处理解算工具快速掌握GNSS解算全流程。从环境搭建、程序编译到核心算法解析,帮助读者理解RTKLIB源码结构,并通过真实数据处理案例演示完整解算过程,是入门GNSS定位技术的实用教程。

weixin_42524226的博客 356

微信小程序-Cannot read property ‘setData‘ of undefined;at api request success callback function(解决)

问题: 微信小程序中提示错误: 源码: onLoad: function() { wx.showLoading({ title: '加载中…', }) try { // var self = this wx.request({ url: app.url+'/xxx', method:'post', data:{ "index":"hello"

13万+

MATLAB PDE工具箱电磁场仿真平行电容板及电偶极子详解

首先打开matlab,在命令行输入pdetool打开PDE工具箱 工具箱的功能我就不赘述了,大概就是以有限元的数值计算方法,计算二阶偏微分方程,因此可以解决电磁场、热力学等问题。 首先点击左上角按钮,画三个矩形 画完一个后可以双击矩形编辑,参数如下: 其中R1表示上极板,R2表示下极板,R3表示整个空间区域。 在上方Set formula为R3-R2-R1,表示求解区域是整个空间区域减去两个极板。下拉框选择Electrostatics表示求解的是静电场问题。 接下来点击上方菜单栏中的这个按钮,表

weixin_42845306的博客 1万+

【微信小程序】code is not defined

@[a] code is not defined;at pages/index/index onLoad function;at api request success callback function ReferenceError: code is not defined

weixin_37629807的博客 2111

微信公众号开发实战:如何高效推送模板消息(附完整代码示例)

本文详细解析了微信公众号开发中模板消息推送的核心流程与实战技巧。文章从OpenID获取、模板申请、Access Token缓存管理到完整PHP代码实现,逐步拆解了高效推送模板消息的关键步骤,并提供了可直接复用的代码示例,帮助开发者快速集成这一提升用户体验的重要功能。

weixin_29009971的博客 791

手把手教你用Multisim仿真ADC接口电路(附峰值采样与电平抬升实战)

本文通过Multisim软件,手把手教学如何构建高保真ADC前端信号调理电路。核心实战内容包括峰值采样保持电路与电平抬升电路的设计、仿真与调试,旨在解决模拟信号接入ADC时遇到的幅度不匹配、负电压等问题,帮助电子设计者快速掌握关键接口电路的实现技巧。

ooo22的博客 255

小程序的thirdScriptError ..... is not a function 报错的解决方法

在这里先说下我做的案例,顺便大家可以看看 项目样式图 前端代码 //前端代码 &lt;!--团队介绍 --&gt; &lt;view class="m-team" wx:if="{{tabs[2].selected}}"&gt; &lt;view bindtap="onTapAddMember" class="m-addBtn"&gt;

咔咔博客 2万+

openharmony之启动恢复子系统详解

需求: 添加一个名为my_service的自定义服务步骤1: 创建服务配置],],"env": [步骤2: 添加到主配置],"jobs": ["cmds": [步骤3: 验证配置# ✅ 检查配置格式 jq . /system/etc/init/my_service.cfg # 🔄 重新加载配置 begetctl reload # 📊 验证服务状态 begetctl dump_service my_serviceOpenHarmony init进程的完整生命周期。🔄 三阶段启动模型⚙️ 配置体系。

m0_67505153的博客 596

【LadyBug】thirdScriptError:api request success callback function,Cannot read property undefine参数

可以看到cash已经取到了值,而且也有定义看网上全说request success callback是因为没有将this.setdata改为that.setdata,但是我的代码写的是that,这就很尴尬了      var Openid = options.openid var that = this that.data.Openid = Openid var my...

taipengdi3963的博客 2万+

交换机端口模式详解:Access、Hybrid、Trunk

交换机是网络中至关重要的组件之一,用于连接各种设备并启用数据的高效流动。为了更好地管理和控制网络流量,交换机提供了不同的端口模式,其中包括Access、Hybrid和Trunk。本文将深入探讨这三种端口模式,详细解释它们的配置、特性和应用场景,以帮助网络管理员更好地理解和优化网络架构。

网络技术联盟站 4013

【WRFDA安装第一期】安装 WRFDA 以运行 3DVAR/4DVAR数据同化

【WRFDA安装第一期】安装 WRFDA 以运行 3DVAR/4DVAR数据同化

WW、forever的博客 1892

thirdScriptError Cannot read property '12' of undefined;at pages/me/me onReady function;at api reque

在获取小程序发出请求后返回数据list里面的具体某个值的报错问题,在我们知道我们后台封装的数据时list集合,但是在小程序的请求后的返回数据类型格式并不是我们所想的一样,那怎样获取,如下: 报错: thirdScriptError Cannot read property ‘12’ of undefined;at pages/me/me onReady function;at api reques...

weixin_44729898的博客 756

YOLOv5源码逐行超详细注释与解读(3)——训练部分train.py

全网最详细的YOLOv5项目源码解读之训练部分train. py。全文近5万字!代码逐行注释,逐段讲解,小白入门必备!

路人贾的博客 3万+

ReferenceError: request is not defined

跟着网上的大佬们敲代码,明明动作一模一样的时候,代码分毫不差的时候,他也会出现前所未知的错误,而且网上根本搜不到那种,在我反复看了大佬的动作之后还是没有找到问题所在。然后我就自己憋了好久,大概有半天的样子,把代码给憋出来了,原因是虽然在引入的js中定义了这个request,但是在网页打开后还是报错,request is not defined ,你TM说神不神奇,为啥我成功的引入这个js,然后我在使用时也会有代码提示,但是运行的时候他就是会报错,咱们就是不能理解。真的是离了个大谱,欺负我经验不足~~~...

m0_60282866的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

thirdScriptError xxx is not defined,小程序的函数要指定当前执行

fuzzyQuery: function (list, keyWord) { var arr = []; for (var i = 0; i < list.length; i++) { if (list[i].match(keyWord) != null) { arr.push(list[i])...

weixin_41033048的博客 2187

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

WxParse:thirdScriptError undefined;at xxx/xxx/xxx onLoad function;at api request success callback

报错得原因是获取得imageDetail数据本身有问题,试着换了换内容就好了,我也是因为有两个地方用到这个方法,另一个页面是好的才想着换一下内容试试。注:这个只是用于自己遇到得问题记录,菜鸟一个也不懂怎么写博客。...

qq_32336869的博客 6273

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

小程序报错坑系列 及解决方法?

错误案例一 Component constructors should be called while initialization. A constructor call has been ignored. Component像页面一样由wxml、wxss、js和json4个文件组成,且需要把这4个文件放在同一个目录中。与页面不一样的是,Component中的构造函数(也可以称构造器)是Co...

午夜灬玫瑰焰钻的博客 1万+

论微信小程序的坑:thirdScriptError TypeError: this.setData is not a function

一枚一起学习,一起进步的小白

cyxevil的博客 4万+

解决微信小程序 thirdScriptError错误

最近入坑了微信小程序,遇到了很多问题,今日份的问题是thirdScriptError! 错误信息如下: 错误版源码(已删除与此错误无关的代码): Page({ data: { //用于保存input的输入内容 words:null }, //获取input输入框的内容 input:function(e){ this.setDat...

qq_42183184的博客 3万+

微信小程序开发过程中总结的注意事项

picker动态取值  objectArray: [       {         id: 12,         name: '环翠区'       },       {         id: 13,         name: '高区'       },       {         id: 14,         name: '经区'       },

隋旭峰的专栏 1万+

微信小程序setdata is not defined;at api request success callback function

经常会在接口的sucess函数里边重置data{}数据,但是直接this.setData是不行的; 须写成var that=this; 如下简易demo onLoad: function (options) { // this.getUser(wx.getStorageSync("userInfo").id); }, getUser:function(userId){ ...

weixin_41326227的博客 2488

异常处理——this.setData is not a function报错处理

WeChat小程序交流(QQ群:769977169)网络请求成功后,设置数据时,报错,内容如下:this.setData is not a function;at pages/index/index onLoad function;at api request success callback function TypeError: this.setData is not a function...

番薯大佬的专栏 1万+
上一篇: 异常:JUnit4 initializationError[Runner:JUnit4](0.001s)的出现与解决
下一篇: 异常:org.apache.ibatis.binding.BindingException: Mapper method 'xyz.mytch.home.dao.HomeDao.findConTota
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值