diff --git a/docs/source/en/core/cookie-and-session.md b/docs/source/en/core/cookie-and-session.md index c81edf3685..48d6527820 100644 --- a/docs/source/en/core/cookie-and-session.md +++ b/docs/source/en/core/cookie-and-session.md @@ -136,7 +136,7 @@ class HomeController extends Controller { const userId = ctx.session.userId; const posts = await ctx.service.post.fetch(userId); // modify session value - ctx.session.visited = ctx.session.visited ? ctx.session.visited++ : 1; + ctx.session.visited = ctx.session.visited ? (ctx.session.visited + 1) : 1; ctx.body = { success: true, posts, diff --git a/docs/source/zh-cn/core/cookie-and-session.md b/docs/source/zh-cn/core/cookie-and-session.md index a969446182..e3e4809cfb 100644 --- a/docs/source/zh-cn/core/cookie-and-session.md +++ b/docs/source/zh-cn/core/cookie-and-session.md @@ -114,7 +114,7 @@ class HomeController extends Controller { const userId = ctx.session.userId; const posts = await ctx.service.post.fetch(userId); // 修改 Session 的值 - ctx.session.visited = ctx.session.visited ? ctx.session.visited++ : 1; + ctx.session.visited = ctx.session.visited ? (ctx.session.visited + 1) : 1; ctx.body = { success: true, posts,