当前位置:网站首页>Solve the syntaxerror: unexpected end of JSON input
Solve the syntaxerror: unexpected end of JSON input
2022-07-25 08:45:00 【xuefankang】
Jump page to pass parameters
var selectWorker = JSON.stringify(selectWorker);
uni.navigateTo({
url: '../recordForm/recordForm?selectWorker=' + selectWorker
})onLoad(option) {
console.log(option)
var _this = this;
// Selected workers
var selectWorker = JSON.parse(option.selectWorker);
var workerIdsArray = [];
for (var i = 0; i < selectWorker.length; i++) {
workerIdsArray.push(selectWorker[i].id);
}
var workerIds = workerIdsArray.join(',');
console.log(workerIds);
_this.selectWorker = selectWorker;
_this.workerIds = workerIds;
},Wrong presentation
SyntaxError:Unexpected end of JSON input
Solution
reason : If the parameters of the object or the elements of the array are encountered, the address includes ?& - _ . ! ~ * ' ( ) When waiting for special symbols , object / The array must first pass JSON.stringify Convert to a string and pass through encodeURIComponent code , Reception time , Through the first decodeURIComponent Decode and pass JSON.parse Convert to JSON Formatted objects / Array .
Revised as follows :
var selectWorker = JSON.stringify(selectWorker);
uni.navigateTo({
url: '../recordForm/recordForm?selectWorker=' + encodeURIComponent(selectWorker)
})onLoad(option) {
console.log(option)
var _this = this;
// Selected workers
var selectWorker = JSON.parse(decodeURIComponent(option.selectWorker));
var workerIdsArray = [];
for (var i = 0; i < selectWorker.length; i++) {
workerIdsArray.push(selectWorker[i].id);
}
var workerIds = workerIdsArray.join(',');
console.log(workerIds);
_this.selectWorker = selectWorker;
_this.workerIds = workerIds;
},边栏推荐
- @Autowired的使用
- 51 MCU peripherals: Motor
- @Autowired注解的实现原理
- 为什么要使用MQ消息中间件?这几个问题必须拿下!
- Source code of pet adoption management system implemented by ssm+jsp+mysql
- Graduation project of wechat small program ordering system of small program completion works (4) opening report
- Database query optimization
- JVM specification Oracle official website
- Efcore's solution of multi tenant zero script, table and database read-write separation under SaaS system
- Source code of short video live broadcast system
猜你喜欢

Source code of pet adoption management system implemented by ssm+jsp+mysql

公寓报修系统(IDEA,SSM,MySQL)

Graduation project of wechat small program ordering system of small program completion works (4) opening report

Memcached data cache database (improve efficiency)

Wechat reservation applet graduation design of applet completion works (1) development outline

Chapter 3 business function development (realize the real-time response of the select all button)

How can hospitals achieve efficient and low-cost operation and maintenance? Is there any software that can meet it?

Huawei device remote login (Telnet, SSH) configuration

Wechat reservation applet graduation project (7) mid term inspection report of applet completion works

PHP reports an error: classes\phpexcel\cell php Line(594) Invalid cell coordinate ESIGN1
随机推荐
Foundation 32: page element positioning method XPath --- axis positioning method
Wechat reservation applet graduation design of applet completion works (3) background function
Wechat reservation of completed works of applet graduation project (4) opening report
Wechat reservation of the completed works of the applet graduation project (6) opening defense ppt
Memcached data cache database (improve efficiency)
Redis4.0.14 sentinel automatic failover failed
Wechat sports ground reservation applet graduation design of applet completion works (3) background function
Yolov5 environment configuration
JD cloud and Forrester consulting released a hybrid cloud report that cloud Nativity has become a new engine driving industrial development
BGP border gateway protocol basic knowledge points
记录两次多端排查问题的过程
LabVIEW experiment - temperature detection system (experimental learning version)
Dirty data and memory leakage of ThreadLocal
BigDecimel转人民币大写
51单片机外设篇:蜂鸣器
C语言基础
51单片机外设篇:电机
Redis学习笔记
智能运维场景解析:如何通过异常检测发现业务系统状态异常
Wechat Reservation Reservation of applet completion works applet graduation project (8) graduation project thesis template