当前位置:网站首页>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;
},边栏推荐
- [untitled]
- unity客户端读取文本配置
- When testing VPN, the IP found by the command line is inconsistent with that of Baidu search
- @Autowired注解的原理
- Force buckle - 1046. Weight of the last stone
- 哈希表刷题(上)
- Wechat reservation of the completed works of the applet graduation project (6) opening defense ppt
- 51 MCU peripherals: buzzer
- 25位撤销博士学位
- 附加:在在下部分区/县(数据表)
猜你喜欢

Freemaker template engine

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

Implementation of depth first and breadth first traversal of binary tree

英特尔就产品延误向Xe HPG寻宝游戏获奖者道歉并公布奖品样貌

TCGA simple download tool V16 installation error

【无标题】

51 MCU peripherals: Motor

When testing VPN, the IP found by the command line is inconsistent with that of Baidu search

C语言基础

51 MCU internal peripherals: timer and counter
随机推荐
Redis fragment cluster
英特尔就产品延误向Xe HPG寻宝游戏获奖者道歉并公布奖品样貌
[shader realizes shadow projection effect _shader effect Chapter 8]
Wechat applet ordering system graduation design of applet completion works (2) applet function
@Autowired的使用
Hash table questions (Part 1)
Chapter 3 business function development (realize the real-time response of the select all button)
Foundation 31: Selenium positioning dynamic ID element
Eureka forced offline service
@Differences between requestparam, @pathparam, @pathvariable and other annotations (use of some annotations)
公寓报修系统(IDEA,SSM,MySQL)
记录两次多端排查问题的过程
Force buckle - 1046. Weight of the last stone
This is the worst controller layer code I've ever seen
Basis 33: XPath acquisition methods of page elements under various browsers
Mogdb 3.0 how to add a standby database in the environment of one active and one standby
When testing VPN, the IP found by the command line is inconsistent with that of Baidu search
附加:中半部分sql语句 区/县(数据表)
Database query optimization
LeetCode·83双周赛·6129.全0子数组的数目·数学