Problem: an error occurs when the page receives the passed JSON object
Reference page:
let invite = {
id:albumID,
unionid,
role
}
wx.navigateTo({
url: `/pages/web/web?id=${id}&isShared=1&invite=${JSON.stringify(invite)}`,
});
Receive page printing parameters:
console.log('invite',this.invite);
//console.log('invite',JSON.parse(this.invite));//报错 SyntaxError: Unexpected token u in JSON at position 0
The result is
Solution:
When receiving JSON data, decodeuri () is used for decoding
let {id,role,unionid} = JSON.parse(decodeURI(this.invite));
Read More:
- [Solved] Error in created hook: “SyntaxError: Unexpected token o in JSON at position 1“
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0
- [Solved] React Startup Error at the First time :SyntaxError: Unexpected token
- [Solved] ajax Error: Uncaught SyntaxError: Unexpected end of JSON input
- [Solved] Uncaught SyntaxError: Unexpected token ‘<‘
- [Solved] Webpack compile error: SyntaxError: Unexpected token =
- [Solved] JSON.parse() Error: Unexpected end of JSON input
- uniapp [Vue warn]: Error in onLoad hook: “TypeError: Attempting to change the setter of an unconfigu
- [Solved] Vue unit test syntax error: unexpected token ‘export‘
- node.js yarn Error: SyntaxError: Unexpected string [How to Solve]
- ArcGIS API for JavaScript version 4. X updated and the project startup error: Module parse failed: Unexpected token(… …
- [Solved] ESLint: Parsing error: Unexpected token(prettier/prettier)
- [Solved] TypeError: Converting circular structure to JSON – JSON.stringify
- uniapp Use render Function Error: [Vue warn]: Error in beforeCreate hook: “TypeError: Cannot read property ‘_i‘ of
- Json.parse: All Error & How to Solve Them
- [Vue warn]: Error in beforeDestroy hook: “Error: [ElementForm]unpected width
- Vue Error: error in mounted hook: TypeError: invalid src type
- Vue Import three.JS error: Unexpected token [How to Solve]
- [Solved] vue Project Error: react lazy eslint error Parsing error: Unexpected token import
- [Solved] Error in mounted hook: “Error: please transfer a valid prop