{"id":2463,"date":"2024-11-10T13:10:58","date_gmt":"2024-11-10T05:10:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2463\/"},"modified":"2024-11-10T13:10:58","modified_gmt":"2024-11-10T05:10:58","slug":"yii-2-0-confirm-%e5%bc%b9%e6%a1%86%e4%b8%8d%e6%98%be%e7%a4%ba%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2463\/","title":{"rendered":"Yii 2.0 Confirm \u5f39\u6846\u4e0d\u663e\u793a\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173077042373728.jpg\" class=\"aligncenter\" title=\"Yii 2.0 Confirm \u5f39\u6846\u4e0d\u663e\u793a\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Yii 2.0 Confirm \u5f39\u6846\u4e0d\u663e\u793a\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>yii 2.0 confirm \u5f39\u6846\u672a\u663e\u793a\u7684\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 yii 2.0 \u7684 confirm \u5f39\u6846\u65f6\uff0c\u53d1\u73b0\u5f39\u6846\u5e76\u672a\u663e\u793a\uff0c\u4ee3\u7801\u6267\u884c\u4e86\u540e\u9762\u7684\u52a8\u4f5c\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5728 yii 2.0 \u4e2d\uff0cconfirm \u5f39\u6846\u7531 yiihelpershtml::a() \u65b9\u6cd5\u751f\u6210\u3002\u6839\u636e\u5b98\u65b9\u6587\u6863\uff0c\u6b63\u786e\u751f\u6210 confirm \u5f39\u6846\u4ee3\u7801\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;?= html::a('\u5220\u9664', ['post\/delete', 'id' =&gt; $post['id']], ['data-confirm' =&gt; '\u786e\u5b9a\u8981\u5220\u9664\u5417\uff1f']) ?&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9700\u8981\u5c06 &#8216;confirm&#8217; \u8bbe\u7f6e\u4e3a &#8216;data-confirm&#8217;\uff0c\u800c\u4e0d\u662f &#8216;data&#8217;\u3002<\/p>\n<p><strong>\u4fee\u6539\u540e\u7684\u89c6\u56fe\u6587\u4ef6<\/strong><\/p>\n<pre>use yiihelpersHtml;\n\necho Html::a(Yii::t('app', 'Delete'), ['delete', 'id' =&gt; $model-&gt;id], [\n    'data-confirm' =&gt; 'Are you sure you want to delete this item?',\n]);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u4fee\u6539\uff0cconfirm \u5f39\u6846\u5373\u53ef\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<p><strong>\u6ce8\u610f<\/strong><\/p>\n<ul>\n<li>&#8216;data-confirm&#8217; \u53c2\u6570\u662f\u4e00\u4e2a html5 \u5c5e\u6027\uff0c\u5b83\u5c06\u88ab\u6d4f\u89c8\u5668\u7528\u6765\u663e\u793a\u4e00\u4e2a\u786e\u8ba4\u5bf9\u8bdd\u6846\u3002<\/li>\n<li>\u5982\u679c\u5728\u6d4f\u89c8\u5668\u4e2d\u7981\u7528 javascript \u6216\u5f39\u6846\u88ab\u6d4f\u89c8\u5668\u963b\u6b62\uff0c\u5219\u786e\u8ba4\u5bf9\u8bdd\u6846\u53ef\u80fd\u4e0d\u4f1a\u663e\u793a\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fYii 2.0 Confirm \u5f39\u6846\u4e0d\u663e\u793a\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>yii 2.0 confirm \u5f39\u6846\u672a\u663e\u793a\u7684\u89e3\u51b3\u65b9\u6cd5 \u95ee\u9898\u63cf\u8ff0 \u5728\u4f7f\u7528 yii 2.0 \u7684 confirm \u5f39\u6846\u65f6\uff0c\u53d1\u73b0\u5f39\u6846\u5e76\u672a\u663e\u793a\uff0c\u4ee3\u7801\u6267\u884c\u4e86\u540e\u9762\u7684\u52a8\u4f5c\u3002 \u89e3\u51b3\u65b9\u6848 \u5728 yii 2.0 \u4e2d\uff0cconfirm \u5f39\u6846\u7531 yiihelpershtml::a() \u65b9\u6cd5\u751f\u6210\u3002\u6839\u636e\u5b98\u65b9\u6587\u6863\uff0c\u6b63\u786e\u751f\u6210 confirm \u5f39\u6846\u4ee3\u7801\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a &lt;?= html::a(&#8216;\u5220\u9664&#8217;, [&#8216;post\/delete&#8217;, &#8216;id&#8217; =&gt; $post[&#8216;id&#8217;]], [&#8216;data-confirm&#8217; =&gt; &#8216;\u786e\u5b9a\u8981\u5220\u9664\u5417\uff1f&#8217;]) ?&gt; \u767b\u5f55\u540e\u590d\u5236 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9700\u8981\u5c06 &#8216;confirm&#8217; \u8bbe\u7f6e\u4e3a &#8216;data-confirm&#8217;\uff0c\u800c\u4e0d\u662f &#8216;data&#8217;\u3002 \u4fee\u6539\u540e\u7684\u89c6\u56fe\u6587\u4ef6 use yiihelpersHtml; echo Html::a(Yii::t(&#8216;app&#8217;, &#8216;Delete&#8217;), [&#8216;delete&#8217;, &#8216;id&#8217; =&gt; $model-&gt;id], [ &#8216;data-confirm&#8217; =&gt; &#8216;Are you sure you want [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2463","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2463"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2463\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}