{"id":16048,"date":"2025-04-18T22:33:28","date_gmt":"2025-04-18T14:33:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/16048.html"},"modified":"2025-04-18T22:33:28","modified_gmt":"2025-04-18T14:33:28","slug":"next-js-v15-%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%93%8d%e4%bd%9c%e4%bb%a5%e5%8f%8a%e8%b0%83%e7%94%a8%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/16048.html","title":{"rendered":"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406"},"content":{"rendered":"<h4>\u7ea6\u5b9a<\/h4>\n<p>\u670d\u52a1\u5668\u64cd\u4f5c\u662f\u5728\u670d\u52a1\u5668\u4e0a\u6267\u884c\u7684\u5f02\u6b65\u51fd\u6570\u3002\u5b83\u4eec\u53ef\u4ee5\u5728\u670d\u52a1\u5668\u7ec4\u4ef6\u548c\u5ba2\u6237\u7aef\u7ec4\u4ef6\u4e2d\u8c03\u7528&#xff0c;\u7528\u4e8e\u5904\u7406 Next.js \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8868\u5355\u63d0\u4ea4\u548c\u6570\u636e\u4fee\u6539\u3002<\/p>\n<p>\u670d\u52a1\u5668\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7 React \u7684 \u201cuse server\u201d \u6307\u4ee4\u5b9a\u4e49\u3002\u4f60\u53ef\u4ee5\u5c06\u8be5\u6307\u4ee4\u653e\u5728 async \u51fd\u6570\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u51fd\u6570\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c&#xff0c;\u6216\u8005\u653e\u5728\u5355\u72ec\u6587\u4ef6\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u6587\u4ef6\u7684\u6240\u6709\u5bfc\u51fa\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\u3002<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">default<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">Page<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u670d\u52a1\u5668\u64cd\u4f5c<\/span><br \/>\n  <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#039;use server&#039;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4fee\u6539\u6570\u636e<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> <span class=\"token string\">&#039;&#8230;&#039;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token string\">&#039;use server&#039;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<h4>\u5e94\u7528<\/h4>\n<p>React \u6269\u5c55\u4e86 HTML \u5143\u7d20&#xff0c;\u5141\u8bb8\u901a\u8fc7 action \u5c5e\u6027\u8c03\u7528\u670d\u52a1\u5668\u64cd\u4f5c\u3002<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">default<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">Page<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">createInvoice<\/span><span class=\"token punctuation\">(<\/span>formData<span class=\"token operator\">:<\/span> FormData<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#039;use server&#039;<\/span><\/p>\n<p>    <span class=\"token keyword\">const<\/span> rawFormData <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      customerId<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;customerId&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      amount<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;amount&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      status<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;status&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u4fee\u6539\u6570\u636e<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u91cd\u65b0\u9a8c\u8bc1\u7f13\u5b58<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&lt;<\/span>form action<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">{<\/span>createInvoice<span class=\"token punctuation\">}<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&#8230;<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>form<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u901a\u5e38&#xff0c;Next.js TypeScript \u63d2\u4ef6\u4f1a\u6807\u8bb0updateItemAction&#xff0c;\u56e0\u4e3a\u51fd\u6570\u901a\u5e38\u4e0d\u80fd\u5728\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u8fb9\u754c\u4e4b\u95f4\u5e8f\u5217\u5316&#xff0c;\u5e8f\u5217\u5316\u662f\u6307\u5c06\u5bf9\u8c61\u8f6c\u6362\u4e3a\u53ef\u4ee5\u5b58\u50a8\u6216\u4f20\u8f93\u7684\u683c\u5f0f\u3002\u51fd\u6570\u5305\u542b\u4e0a\u4e0b\u6587\u548c\u72b6\u6001\u4fe1\u606f&#xff0c;\u65e0\u6cd5\u7b80\u5355\u5730\u8f6c\u5316\u4e3a\u53ef\u4ee5\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u6267\u884c\u7684\u683c\u5f0f\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u540d\u4e3a action \u6216\u4ee5 Action \u7ed3\u5c3e\u7684 props \u88ab\u5047\u5b9a\u4e3a\u63a5\u6536\u670d\u52a1\u5668\u64cd\u4f5c\u3002 \u8fd9\u53ea\u662f\u4e00\u4e2a\u542f\u53d1\u5f0f\u65b9\u6cd5&#xff0c;\u56e0\u4e3a TypeScript \u63d2\u4ef6\u5b9e\u9645\u4e0a\u5e76\u4e0d\u77e5\u9053\u5b83\u63a5\u6536\u7684\u662f\u670d\u52a1\u5668\u64cd\u4f5c\u8fd8\u662f\u666e\u901a\u51fd\u6570\u3002 \u8fd0\u884c\u65f6\u7c7b\u578b\u68c0\u67e5\u4ecd\u7136\u4f1a\u786e\u4fdd\u4f60\u4e0d\u4f1a\u610f\u5916\u5730\u5c06\u51fd\u6570\u4f20\u9012\u7ed9\u5ba2\u6237\u7aef\u7ec4\u4ef6\u3002 \u5904\u7406\u8868\u5355\u65f6\u4f60\u53ef\u4ee5\u5c06\u670d\u52a1\u5668\u64cd\u4f5c\u4e0euseActionState\u7ed3\u5408\u4f7f\u7528<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">default<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">Page<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">const<\/span> initialState<span class=\"token operator\">:<\/span> State <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span> message<span class=\"token operator\">:<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">,<\/span> errors<span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token punctuation\">[<\/span>state<span class=\"token punctuation\">,<\/span> formAction<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">useActionState<\/span><span class=\"token punctuation\">(<\/span>createInvoice<span class=\"token punctuation\">,<\/span> initialState<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">createInvoice<\/span><span class=\"token punctuation\">(<\/span>prevState<span class=\"token operator\">:<\/span> State<span class=\"token punctuation\">,<\/span> formData<span class=\"token operator\">:<\/span> FormData<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#039;use server&#039;<\/span><\/p>\n<p>    <span class=\"token keyword\">const<\/span> rawFormData <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      customerId<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;customerId&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      amount<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;amount&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      status<span class=\"token operator\">:<\/span> formData<span class=\"token punctuation\">.<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;status&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u4fee\u6539\u6570\u636e<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u91cd\u65b0\u9a8c\u8bc1\u7f13\u5b58<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&lt;<\/span>form action<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">{<\/span>formAction<span class=\"token punctuation\">}<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&#8230;<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>form<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4f20\u9012\u53e6\u5916\u53c2\u6570 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418143327-680262b77265d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u670d\u52a1\u5668\u64cd\u4f5c\u5c06\u63a5\u6536 userId \u53c2\u6570&#xff0c;\u4ee5\u53ca\u8868\u5355\u6570\u636e:<\/p>\n<p><span class=\"token string\">&#039;use server&#039;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">updateUser<\/span><span class=\"token punctuation\">(<\/span>userId<span class=\"token punctuation\">,<\/span> formData<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7a0b\u5e8f\u5316\u8868\u5355\u63d0\u4ea4 \u4f60\u53ef\u4ee5\u4f7f\u7528 requestSubmit() \u65b9\u6cd5\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u89e6\u53d1\u8868\u5355\u63d0\u4ea4\u3002\u4f8b\u5982&#xff0c;\u5f53\u7528\u6237\u4f7f\u7528 \u2318 &#043; Enter \u952e\u76d8\u5feb\u6377\u952e\u63d0\u4ea4\u8868\u5355\u65f6&#xff0c;\u4f60\u53ef\u4ee5\u76d1\u542c onKeyDown \u4e8b\u4ef6<\/p>\n<p><span class=\"token string\">&#039;use client&#039;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">Entry<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> <span class=\"token function-variable function\">handleKeyDown<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>e<span class=\"token operator\">:<\/span> React<span class=\"token punctuation\">.<\/span>KeyboardEvent<span class=\"token operator\">&lt;<\/span>HTMLTextAreaElement<span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n      <span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">.<\/span>ctrlKey <span class=\"token operator\">||<\/span> e<span class=\"token punctuation\">.<\/span>metaKey<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&amp;&amp;<\/span><br \/>\n      <span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">.<\/span>key <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token string\">&#039;Enter&#039;<\/span> <span class=\"token operator\">||<\/span> e<span class=\"token punctuation\">.<\/span>key <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token string\">&#039;NumpadEnter&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      e<span class=\"token punctuation\">.<\/span><span class=\"token function\">preventDefault<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n      e<span class=\"token punctuation\">.<\/span>currentTarget<span class=\"token punctuation\">.<\/span>form<span class=\"token operator\">?.<\/span><span class=\"token function\">requestSubmit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span>div<span class=\"token operator\">&gt;<\/span><br \/>\n      <span class=\"token operator\">&lt;<\/span>textarea name<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;entry&#034;<\/span> rows<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">{<\/span><span class=\"token number\">20<\/span><span class=\"token punctuation\">}<\/span> required onKeyDown<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">{<\/span>handleKeyDown<span class=\"token punctuation\">}<\/span> <span class=\"token operator\">\/<\/span><span class=\"token operator\">&gt;<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">\/<\/span>div<span class=\"token operator\">&gt;<\/span><br \/>\n  <span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>\u539f\u7406<\/h4>\n<p>\u6bcf\u5f53\u4f60\u5c06 \u2018use server\u2019 \u6dfb\u52a0\u5230\u670d\u52a1\u5668\u7aef\u51fd\u6570\u5e76\u5c06\u5176\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u7ec4\u4ef6\u65f6&#xff0c;\u5b83\u90fd\u4f1a\u5c06\u5176\u6807\u8bb0\u4e3a\u5bf9\u5ba2\u6237\u7aef\u53ef\u7528&#xff08;\u670d\u52a1\u5668\u7684\u5165\u53e3\u70b9&#xff09;\u3002\u8fd9\u5e76\u4e0d\u610f\u5473\u7740\u51fd\u6570\u4f1a\u88ab\u5e8f\u5217\u5316\u5e76\u901a\u8fc7\u7f51\u7edc\u53d1\u9001&#xff0c;\u76f8\u53cd&#xff0c;\u5ba2\u6237\u7aef\u5c06\u83b7\u5f97\u8be5\u51fd\u6570\u7684 URL \u5b57\u7b26\u4e32&#xff0c;\u5ba2\u6237\u7aef\u53ef\u4ee5\u4f7f\u7528\u5b83\u901a\u8fc7 RPC \u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u3002\u8fd9\u662f\u4e00\u4e2a POST \u8bf7\u6c42\u3002\u8fd9\u662f\u81ea\u52a8\u4e3a\u4f60\u5904\u7406\u7684&#xff0c;\u4f60\u6240\u8981\u505a\u7684\u5c31\u662f\u5305\u542b \u2018use server\u2019&#xff0c;\u5bfc\u5165\u4f60\u7684 server action \u6216\u5c06\u5176\u4f5c\u4e3a prop \u4f20\u9012&#xff0c;\u7136\u540e\u5c31\u4f7f\u7528\u5b83\u3002\u60a8\u6c38\u8fdc\u4e0d\u4f1a\u770b\u5230\u6b64 URL \u5b57\u7b26\u4e32&#xff0c;\u4f46\u8fd9\u5c31\u662f\u5b83\u5728\u540e\u53f0\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002<\/p>\n<p>\u5373\u4f7f\u60a8\u5728 server \u7ec4\u4ef6\u4e2d\u4f7f\u7528 server \u64cd\u4f5c&#xff0c;\u6dfb\u52a0 \u201cuse server\u201d \u4e5f\u5f88\u91cd\u8981\u3002\u5047\u8bbe\u60a8\u5728\u670d\u52a1\u5668\u7ec4\u4ef6\u4e2d\u6709\u4e00\u4e2a\u6309\u94ae&#xff0c;\u5e76\u4e14\u60a8\u5e0c\u671b\u5728\u6709\u4eba\u5355\u51fb\u8be5\u6309\u94ae\u65f6\u4f7f\u7528\u670d\u52a1\u5668\u64cd\u4f5c\u3002\u60a8\u4ecd\u7136\u9700\u8981\u4e00\u4e2a URL \u5b57\u7b26\u4e32&#xff0c;\u56e0\u4e3a\u8be5\u6309\u94ae\u6700\u7ec8\u4f1a\u51fa\u73b0\u5728\u5ba2\u6237\u7aef\u4e0a&#xff0c;\u5e76\u70b9\u51fb\u8be5\u6309\u94ae\u3002\u56e0\u6b64&#xff0c;\u53ea\u6709\u5f53\u4f60\u5728 server \u64cd\u4f5c\u4e2d\u5305\u542b \u201cuse server\u201d \u6307\u4ee4\u65f6&#xff0c;\u5b83\u624d\u4f1a\u8d77\u4f5c\u7528\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u5982\u679c\u4f60\u5c06\u670d\u52a1\u5668\u64cd\u4f5c\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u7ec4\u4ef6\u4e2d&#xff0c;\u4f46\u5fd8\u8bb0\u6dfb\u52a0 \u201cuse server\u201d&#xff0c;\u5b83\u4f1a\u5c06\u8be5\u51fd\u6570\u4f5c\u4e3a\u4ee3\u7801\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u4e2d\u3002\u5b83\u5c06\u4e0d\u518d\u662f\u670d\u52a1\u5668\u7aef\u529f\u80fd\u3002\u5f53\u4f60\u6dfb\u52a0 \u201cuse server\u201d \u65f6&#xff0c;\u5b83\u4f1a\u8ba9\u8be5\u51fd\u6570\u4fdd\u7559\u5728\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u8fd9\u662f\u81ea\u52a8\u4e3a\u4f60\u5904\u7406\u7684\uff0c\u4f60\u6240\u8981\u505a\u7684\u5c31\u662f\u5305\u542b \u2018use server\u2019\uff0c\u5bfc\u5165\u4f60\u7684 server action \u6216\u5c06\u5176\u4f5c\u4e3a prop \u4f20\u9012\uff0c\u7136\u540e\u5c31\u4f7f\u7528\u5b83\u3002\u56e0\u6b64\uff0c\u53ea\u6709\u5f53\u4f60\u5728 server \u64cd\u4f5c\u4e2d\u5305\u542b \u201cuse server\u201d \u6307\u4ee4\u65f6\uff0c\u5b83\u624d\u4f1a\u8d77\u4f5c\u7528\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f60\u5c06\u670d\u52a1\u5668\u64cd\u4f5c\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u7ec4\u4ef6\u4e2d\uff0c\u4f46\u5fd8\u8bb0\u6dfb\u52a0 \u201cuse server\u201d\uff0c\u5b83\u4f1a\u5c06\u8be5\u51fd\u6570\u4f5c\u4e3a\u4ee3\u7801\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u4e2d\u3002\u5b83\u5c06\u4e0d\u518d\u662f\u670d\u52a1\u5668\u7aef\u529f\u80fd\u3002\u4f60\u53ef\u4ee5\u5c06\u8be5\u6307\u4ee4\u653e\u5728 async \u51fd\u6570\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u51fd\u6570\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\uff0c\u6216\u8005\u653e\u5728\u5355\u72ec\u6587\u4ef6\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u6587\u4ef6\u7684\u6240\u6709\u5bfc\u51fa\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\u3002_nextjs 15 \u670d\u52a1\u7aef\u8bf7\u6c42<\/p>\n","protected":false},"author":2,"featured_media":16047,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[943,87],"topic":[],"class_list":["post-16048","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-next-js","tag-87"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/16048.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u8fd9\u662f\u81ea\u52a8\u4e3a\u4f60\u5904\u7406\u7684\uff0c\u4f60\u6240\u8981\u505a\u7684\u5c31\u662f\u5305\u542b \u2018use server\u2019\uff0c\u5bfc\u5165\u4f60\u7684 server action \u6216\u5c06\u5176\u4f5c\u4e3a prop \u4f20\u9012\uff0c\u7136\u540e\u5c31\u4f7f\u7528\u5b83\u3002\u56e0\u6b64\uff0c\u53ea\u6709\u5f53\u4f60\u5728 server \u64cd\u4f5c\u4e2d\u5305\u542b \u201cuse server\u201d \u6307\u4ee4\u65f6\uff0c\u5b83\u624d\u4f1a\u8d77\u4f5c\u7528\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f60\u5c06\u670d\u52a1\u5668\u64cd\u4f5c\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u7ec4\u4ef6\u4e2d\uff0c\u4f46\u5fd8\u8bb0\u6dfb\u52a0 \u201cuse server\u201d\uff0c\u5b83\u4f1a\u5c06\u8be5\u51fd\u6570\u4f5c\u4e3a\u4ee3\u7801\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u4e2d\u3002\u5b83\u5c06\u4e0d\u518d\u662f\u670d\u52a1\u5668\u7aef\u529f\u80fd\u3002\u4f60\u53ef\u4ee5\u5c06\u8be5\u6307\u4ee4\u653e\u5728 async \u51fd\u6570\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u51fd\u6570\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\uff0c\u6216\u8005\u653e\u5728\u5355\u72ec\u6587\u4ef6\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u6587\u4ef6\u7684\u6240\u6709\u5bfc\u51fa\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\u3002_nextjs 15 \u670d\u52a1\u7aef\u8bf7\u6c42\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/16048.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T14:33:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418143327-680262b77265d.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16048.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/16048.html\",\"name\":\"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T14:33:28+00:00\",\"dateModified\":\"2025-04-18T14:33:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/16048.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/16048.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/16048.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/16048.html","og_locale":"zh_CN","og_type":"article","og_title":"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u8fd9\u662f\u81ea\u52a8\u4e3a\u4f60\u5904\u7406\u7684\uff0c\u4f60\u6240\u8981\u505a\u7684\u5c31\u662f\u5305\u542b \u2018use server\u2019\uff0c\u5bfc\u5165\u4f60\u7684 server action \u6216\u5c06\u5176\u4f5c\u4e3a prop \u4f20\u9012\uff0c\u7136\u540e\u5c31\u4f7f\u7528\u5b83\u3002\u56e0\u6b64\uff0c\u53ea\u6709\u5f53\u4f60\u5728 server \u64cd\u4f5c\u4e2d\u5305\u542b \u201cuse server\u201d \u6307\u4ee4\u65f6\uff0c\u5b83\u624d\u4f1a\u8d77\u4f5c\u7528\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f60\u5c06\u670d\u52a1\u5668\u64cd\u4f5c\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u7ec4\u4ef6\u4e2d\uff0c\u4f46\u5fd8\u8bb0\u6dfb\u52a0 \u201cuse server\u201d\uff0c\u5b83\u4f1a\u5c06\u8be5\u51fd\u6570\u4f5c\u4e3a\u4ee3\u7801\u5bfc\u5165\u5230\u5ba2\u6237\u7aef\u4e2d\u3002\u5b83\u5c06\u4e0d\u518d\u662f\u670d\u52a1\u5668\u7aef\u529f\u80fd\u3002\u4f60\u53ef\u4ee5\u5c06\u8be5\u6307\u4ee4\u653e\u5728 async \u51fd\u6570\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u51fd\u6570\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\uff0c\u6216\u8005\u653e\u5728\u5355\u72ec\u6587\u4ef6\u7684\u9876\u90e8\u4ee5\u5c06\u8be5\u6587\u4ef6\u7684\u6240\u6709\u5bfc\u51fa\u6807\u8bb0\u4e3a\u670d\u52a1\u5668\u64cd\u4f5c\u3002_nextjs 15 \u670d\u52a1\u7aef\u8bf7\u6c42","og_url":"https:\/\/www.wsisp.com\/helps\/16048.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T14:33:28+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418143327-680262b77265d.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/16048.html","url":"https:\/\/www.wsisp.com\/helps\/16048.html","name":"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T14:33:28+00:00","dateModified":"2025-04-18T14:33:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/16048.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/16048.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/16048.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Next.js v15 - \u670d\u52a1\u5668\u64cd\u4f5c\u4ee5\u53ca\u8c03\u7528\u539f\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/16048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=16048"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/16048\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/16047"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=16048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=16048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=16048"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=16048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}