{"id":7711,"date":"2017-03-26T22:55:02","date_gmt":"2017-03-26T13:55:02","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=7711"},"modified":"2026-04-06T04:34:34","modified_gmt":"2026-04-05T19:34:34","slug":"vue-js-%e3%81%8c%e4%ba%88%e6%83%b3%e4%bb%a5%e4%b8%8a%e3%81%ab%e8%89%af%e3%81%8b%e3%81%a3%e3%81%9f%e3%81%ae%e3%81%a7%e3%80%81%e6%97%a2%e5%ad%98wordpress%e3%81%ab%e5%b0%8e%e5%85%a5%e3%80%82vue-js-vue-2","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=7711","title":{"rendered":"Vue.js \u304c\u4e88\u60f3\u4ee5\u4e0a\u306b\u826f\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u5b58WordPress\u306b\u5c0e\u5165\u3002Vue.js (vue-class-component) + TypeScript + WordPress \u3067\u4f5c\u308b\u3001\u8a18\u4e8b\u8aad\u307f\u8fbc\u307f component \u300c\u5b9f\u88c5\u7de8\u300d"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-7676\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb.png\" alt=\"\" width=\"600\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb.png 1914w, https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb-300x161.png 300w, https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb-768x413.png 768w, https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb-1024x551.png 1024w, https:\/\/www.webcyou.com\/wp-content\/uploads\/f91bf60971cc8e5761d6dc4db12368cb-900x484.png 900w\" sizes=\"(max-width: 1914px) 100vw, 1914px\" \/><\/p>\n<p>\u3053\u3061\u3089\u306e\u7d9a\u304d\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/?p=7591\">Vue.js \u304c\u4e88\u60f3\u4ee5\u4e0a\u306b\u826f\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u5b58WordPress\u306b\u5c0e\u5165\u3002Vue.js (vue-class-component) + TypeScript + WordPress \u3067\u4f5c\u308b\u3001\u8a18\u4e8b\u8aad\u307f\u8fbc\u307f component \u300c\u74b0\u5883\u69cb\u7bc9\u7de8\u300d<\/a><\/p>\n<p>\u3067\u306f\u3001\u524d\u56de\u306e\u7d9a\u304d\u304b\u3089\u3001<\/p>\n<p><strong>components\/post-more-btn.html<\/strong><\/p>\n<pre><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&amp;lt;div class=&amp;quot;moreBtnBox&amp;quot;&amp;gt;\n  &amp;lt;a @click=&amp;quot;onClick&amp;quot;&amp;gt;\u4ed6\u306e\u8a18\u4e8b\u3092\u8aad\u307f\u8fbc\u3080&amp;lt;\/a&amp;gt;\n&amp;lt;\/div&amp;gt;<\/pre>\n<p>components\u3067\u3042\u308b\u3001\u300c<strong>post-more-btn.html<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u305d\u306e\u5bfe\u3068\u306a\u308b \u300c<strong>post-more-btn.ts<\/strong>\u300d\u306e\u300c<strong>PostMoreBtn<\/strong>\u300d \u306eonClick\u304c\u5b9f\u884c\u3055\u308c\u308b\u6d41\u308c\u3067\u3057\u305f\u3002<\/p>\n<p><strong>components\/post-more-btn.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">import Vue = require('vue');\nimport Component from 'vue-class-component';\nimport PostMoreService from '..\/service\/post-more.service';\nimport bus from '..\/bus'\n\n@Component({\n  props: &#x5B;'nowPostNum'],\n  template: require('.\/post-more-btn.html')\n})\nexport class PostMoreBtn extends Vue {\n  private nowPostNum: number;\n  private postMoreService: PostMoreService = new PostMoreService();\n\n  onClick (): void {\n    this.postMoreService.fetchData(this.nowPostNum)\n      .then((response: any) =&amp;gt;; {\n        bus.$emit('update-post', response.data);\n\n        this.nowPostNum += 10;\n      }, (error: any) =&amp;gt; {\n        console.error(error);\n      });\n  }\n}<\/pre>\n<p>onClick\u95a2\u6570\u3092\u898b\u3066\u307f\u308b\u3068\u3001<strong>postMoreService<\/strong>\u306e<strong>fetchData<\/strong>\u3092\u884c\u3063\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e<strong>postMoreService<\/strong>\u3092\u898b\u3066\u307f\u308b\u3068\u3001\u3053\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>service\/post-more.service.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const axios = require('axios'),\n      wpAjaxUrl = window&#x5B;'wpAjaxUrl'];\n\nexport default class PostMoreService {\n  private formData = new FormData();\n\n  constructor() {\n    this.formData.append('action', 'get_more_post');\n  }\n\n  public fetchData(nowPostNum: number): any {\n    this.formData.append('now_post_num', nowPostNum);\n\n    return axios({\n      method: 'post',\n      url: wpAjaxUrl,\n      data: this.formData\n    });\n  }\n}<\/pre>\n<p>formData\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092private\u3067\u4fdd\u6301\u3057\u3066\u3044\u308b\u306e\u306f\u3001wordpress\u3067Ajax\u901a\u4fe1\u3059\u308b\uff08POST\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\uff09\u969b\u3001<br \/>\nRequestHeader\u306econtent-type\u304c\u300c<strong>application\/x-www-form-urlencoded<\/strong>\u300d\u3067\u3042\u308b\u5fc5\u8981\u3067\u3042\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>jQuery\u306a\u3069\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u3001$.ajax()\u3092\u7528\u3044\u3066Ajax\u901a\u4fe1\u3059\u308b\u969b\u306f\u3001jQuery\u5074\u304c\u3088\u3057\u306a\u306b\u3084\u3063\u3066\u304f\u308c\u3066\u3044\u308b\u304b\u3082\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u3001\u7279\u306b\u3001jQuery\u7b49\u3082\u4f7f\u308f\u305a\u300c<strong>axios<\/strong>\u300d\u3092\u7528\u3044\u3066Ajax\u901a\u4fe1\u3057\u3066\u3044\u308b\u306e\u3067\u3001formData\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>PostMoreService\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u308b\u969b\u306b\u5b9f\u884c\u3055\u308c\u308bconstructor\u95a2\u6570\u306b\u66f8\u304b\u308c\u3066\u3044\u308b<\/p>\n<pre><pre class=\"brush: plain; title: ; notranslate\" title=\"\">this.formData.append('action', 'get_more_post');<\/pre>\n<p>\u306f\u3001formData\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b action\u540d\u3067\u3042\u308b\u300c<strong>get_more_post<\/strong>\u300d\u3092append\u3057\u3001Ajax\u901a\u4fe1\u5f8c\u306ewordpress\u5074\u306e\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>axios\u306fAjax\u901a\u4fe1\u5f8c\u3001<strong>Promise<\/strong>\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u306e\u3067\u3001axios\u95a2\u6570\u81ea\u4f53\u3092return\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>service\/post-more.service.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">return axios({\n  method: 'post',\n  url: wpAjaxUrl,\n  data: this.formData\n});<\/pre>\n<p>API\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3067\u3042\u308b\u3001\u300c<strong>wpAjaxUrl<\/strong>\u300d\u306f\u3001tml\u5074\u3067\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u3063\u3066\u3044\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001wordpress\u3067\u7528\u610f\u3055\u308c\u3066\u3044\u308bAjax\u306e\u7d4c\u8def\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u8a72\u5f53\u306e\u30d5\u30a1\u30a4\u30eb\uff08\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\uff09\u306f\u3001\u300c<strong>wp-admin\/admin-ajax.php<\/strong>\u300d\u3068\u306a\u308a\u3001\u305d\u3061\u3089\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u7d4c\u8def\u304c\u4e00\u822c\u7684\u306b\u3001\u300c<strong>wordpress\u3067\u306eAjax\u7d4c\u8def<\/strong>\u300d\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&amp;lt;script&amp;gt;var wpAjaxUrl = '&amp;lt;?php echo admin_url('admin-ajax.php'); ?&amp;gt;';&amp;lt;\/script&amp;gt;<\/pre>\n<p>admin_url\u95a2\u6570\u306b\u300c&#8217;<strong>admin-ajax.php<\/strong>&#8216;\u300d\u306e\u5f15\u6570\u3092\u6e21\u3059\u3053\u3068\u3067\u3001wordpress\u306eAjax\u306epath\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>wordpress\u5074<\/h4>\n<h5>Ajax\u7528\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u306b\u767b\u9332<\/h5>\n<p><strong>function.php<\/strong><\/p>\n<pre><pre class=\"brush: php; title: ; notranslate\" title=\"\">add_action( 'wp_ajax_get_more_post', 'get_more_post' );\nadd_action( 'wp_ajax_nopriv_get_more_post', 'get_more_post' );<\/pre>\n<p>\u3053\u306e\u95a2\u6570\u3092\u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u306b\u767b\u9332\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u51e6\u7406\u3092\u3059\u308badd_action\u30e1\u30bd\u30c3\u30c9\u304c\u4e8c\u3064\u3042\u308a\u307e\u3059\u304c\u3001\u4e00\u3064\u76ee\u306f\u30ed\u30b0\u30a4\u30f3\u72b6\u614b\u3067\u306e\u767b\u9332\u3067\u3001\u4e8c\u3064\u76ee\u306f\u975e\u30ed\u30b0\u30a4\u30f3\u72b6\u614b\u3067\u306e\u767b\u9332\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>function.php<\/strong><\/p>\n<pre><pre class=\"brush: php; title: ; notranslate\" title=\"\">function get_more_post() {\n  global $wpdb;\n\n  $now_post_num = $_POST&#x5B;'now_post_num'];\n  $get_post_num = 10;\n\n  $sql = &amp;quot;SELECT\n            $wpdb-&amp;gt;posts.ID,\n            $wpdb-&amp;gt;posts.post_title,\n            $wpdb-&amp;gt;posts.post_content\n          FROM\n            $wpdb-&amp;gt;posts\n          WHERE\n            $wpdb-&amp;gt;posts.post_type = 'post'\n          AND\n            $wpdb-&amp;gt;posts.post_status = 'publish'\n          ORDER BY\n            $wpdb-&amp;gt;posts.post_date\n          DESC\n            LIMIT $now_post_num, $get_post_num&amp;quot;;\n\n  echo create_post_json($wpdb-&amp;gt;get_results($sql));\n\n  die();\n}\n\nfunction create_post_json($posts) {\n  $post_list = array();\n\n  foreach($posts as $post) {\n    $postId = $post-&amp;gt;ID;\n\n    $post_list&#x5B;] = array(\n      &amp;quot;title&amp;quot;        =&amp;gt; $post-&amp;gt;post_title,\n      &amp;quot;date&amp;quot;         =&amp;gt; get_the_date(&amp;quot;Y\u5e74n\u6708j\u65e5 l&amp;quot;, $postId),\n      &amp;quot;imageUrl&amp;quot;     =&amp;gt; get_post_image_src($postId),\n      &amp;quot;postUrl&amp;quot;      =&amp;gt; get_permalink($postId),\n      &amp;quot;postDetail&amp;quot;   =&amp;gt; mb_substr(strip_tags($post-&amp;gt;post_content), 0, 160).'\u2026',\n      &amp;quot;tagList&amp;quot;      =&amp;gt; create_post_tag_list(get_the_tags($post-&amp;gt;ID)),\n      &amp;quot;categoryList&amp;quot; =&amp;gt; create_post_category_list(get_the_category($postId))\n    );\n  }\n\n  return json_encode($post_list);\n}<\/pre>\n<p><strong>get_more_post\u95a2\u6570<\/strong>\u306f\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u30d5\u30c3\u30af\u3068\u7d50\u3073\u3064\u3044\u3066\u304a\u308a\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u4f55\u4ef6\u76ee\u304b\u3089\u8a18\u4e8b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u304b\u3092\u3001\u300c<strong>now_post_num<\/strong>\u300d\u3092post\u30c7\u30fc\u30bf\u3067\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002<\/p>\n<p>global\u5909\u6570\u3067\u3042\u308b\u300c<strong>$wpdb<\/strong>\u300d\u3092\u4f7f\u7528\u3057\u3001SQL\u6587\u3092\u767a\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u3067return\u3092\u4f7f\u3063\u3066\u3044\u306a\u3044\u306e\u306f\u3001return\u3092\u4f7f\u7528\u3059\u308b\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u306b0\u304c\u8fd4\u3063\u3066\u3057\u307e\u3046\u70ba\u3001die()\u3067\u51e6\u7406\u3092\u7d42\u308f\u3089\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>create_post_json\u95a2\u6570<\/strong>\u306f\u3001\u30d5\u30ed\u30f3\u30c8\u7528\u306bjson\u30c7\u30fc\u30bf\u3068\u3057\u3066\u52a0\u5de5\u3059\u308b\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067VueJS\u5074\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u3042\u308b\u3001\u300c<strong>postMoreService<\/strong>\u300d\u3068\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u5074\u306ewordpress\u306efunction.php\u306e\u6e96\u5099\u304c\u6574\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u6700\u5f8c\u306f\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u3063\u3066\u6765\u305f\u5f8c\u306e\u3001pub\/sub\u306e\u5f79\u5272\u3092\u6301\u3064bus\u306b\u3064\u3044\u3066\u3067\u3059\u3002<\/p>\n<h4>\u89aa\u5b50\u9593\u4ee5\u5916\u306e\u901a\u4fe1\u3092\u884c\u3046 \u300cbus\u300d<\/h4>\n<p>\u89aa\u5b50\u95a2\u4fc2\u3067\u306f\u306a\u30442\u3064\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u901a\u4fe1\u3092\u884c\u3046\u5834\u5408\u306f\u3001\u300cbus\u300d\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001\u7a7a\u306e Vue \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4e2d\u5fc3\u306e\u30a4\u30d9\u30f3\u30c8\u30d0\u30b9\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>\u516c\u5f0f\u30ac\u30a4\u30c9\u30da\u30fc\u30b8\u3088\u308a<\/strong><\/p>\n<p><a href=\"https:\/\/jp.vuejs.org\/v2\/guide\/components.html#\u89aa\u5b50\u9593\u4ee5\u5916\u306e\u901a\u4fe1\" target=\"_blank\" rel=\"noopener\">\u89aa\u5b50\u9593\u4ee5\u5916\u306e\u901a\u4fe1<\/a><\/p>\n<p><strong>bus.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var bus = new Vue();<\/pre>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/ \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 A \u306e\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3067\nbus.$emit('id-selected', 1)<\/pre>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/ \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 B \u306e created \u30d5\u30c3\u30af\u3067\nbus.$on('id-selected', function (id) {\n  \/\/ ...\n})<\/pre>\n<p>\u3068\u3001\u516c\u5f0f\u30ac\u30a4\u30c9\u30da\u30fc\u30b8\u3068\u3042\u307e\u308a\u8aac\u660e\u3082\u306a\u304f\u3001\u5b9f\u969b\u306b\u3082\u3042\u307e\u308a\u8aac\u660e\u3059\u308b\u3053\u3068\u3082\u306a\u3044\u306e\u3067\u3059\u304c\u3002\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u3056\u3063\u304f\u308a\u8a00\u3046\u3068\u3001\u300cEventEmitter\u7684\u306a\u632f\u308b\u821e\u3044\u304c\u3001\u7a7a\u306e Vue\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3088\u300d\u3068\u3001\u3044\u3063\u305f\u611f\u3058\u3067\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u3001\u524d\u56de\u306e\u8a18\u4e8b\u306b\u632f\u308a\u8fd4\u308a\u3001\u300c<a href=\"https:\/\/www.webcyou.com\/?p=7591\">Vue.js \u304c\u4e88\u60f3\u4ee5\u4e0a\u306b\u826f\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u5b58WordPress\u306b\u5c0e\u5165\u3002Vue.js (vue-class-component) + TypeScript + WordPress \u3067\u4f5c\u308b\u3001\u8a18\u4e8b\u8aad\u307f\u8fbc\u307f component \u300c\u74b0\u5883\u69cb\u7bc9\u7de8<\/a>\u300d\u300d\u3067\u3001\u4f5c\u6210\u3057\u305f post-list.ts\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>components\/post-list.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">created() {\n  bus.$on('update-post', this.onUpdatePost)\n}\n\ndestroyed() {\n  bus.$off('update-post', this.onUpdatePost)\n}<\/pre>\n<p>post-list.ts\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u300ccreated\u95a2\u6570\u300d\u306f\u3001component\u751f\u6210\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5b9f\u884c\u3055\u308c\u3001destroyed\u95a2\u6570\u306f\u305d\u306e\u9006\u3067\u3001components\u304c\u7834\u68c4\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001component\u751f\u6210\u3055\u308c\u308b\u3068\u540c\u6642\u306b\u3001\u300cbus.$on\u300d\u3067update-post\u3092\u8cfc\u8aad\u767b\u9332\u3057\u3001this.onUpdatePost\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001components\u304c\u7834\u68c4\u3055\u308c\u308b\u3068\u540c\u6642\u306b\u3001\u300cbus.$off\u300d\u3067update-post\u3092\u8cfc\u8aad\u89e3\u9664\u3092\u884c\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001post-more.service\u3067\u306f\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u308b\u3068\u3001update-post\u304cemit\u3055\u308c\u3001<strong>components\/post-list.ts<\/strong><br \/>\n\u5074\u306ethis.onUpdatePost\u95a2\u6570\u304c\u547c\u3073\u51fa\u3055\u308c\u3001\u8a18\u4e8b\u30ea\u30b9\u30c8\u3067\u3042\u308b components\u306e\u3001\u300ccomponents\/post-list.html\u300d\u304c\u66f4\u65b0\u3055\u308c\u308b\u6d41\u308c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>service\/post-more.service.ts<\/strong><\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">bus.$emit('update-post', response.data);<\/pre>\n<p>\u3068\u3001\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u3057\u305f\u304c\u3001\u300cwordpress\u300d\u3068\u300cVue Class component\u300d\u3092\u4f7f\u3063\u305f\u3001\u300c\u3082\u3063\u3068\u8a18\u4e8b\u3092\u8aad\u307f\u8fbc\u3080\u300d\u306e\u6d41\u308c\u3067\u3057\u305f\u3002<\/p>\n<p>\u306a\u3093\u3068\u306a\u304f\u3001<strong>\u300cAngular\u300d<\/strong>\u306b\u8fd1\u3044\u611f\u3058\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001<strong>\u300cAngular\u300d<\/strong>\u3092\u4f7f\u3046\u3068\u306a\u308b\u3068\u3001\u30ac\u30c3\u30c4\u30ea\u300cSPA\u300d\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u4eca\u56de\u306e\u69d8\u306a\u3001\u3061\u3087\u3063\u3068\u3057\u305f\u6a5f\u80fd\u306b\u306f\u3001\u624b\u8efd\u306b\u3059\u3050\u306b\u5b9f\u88c5\u3067\u304d\u308b\u300cVue Class component\u300d\u304c\u826f\u3044\u6c17\u304c\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u306f\u3001\u300c\u30ab\u30c6\u30b4\u30ea\u300d\u3068\u304b\u306b\u5168\u304f\u8003\u616e\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5de5\u592b\u3057\u3066\u4f5c\u3063\u3066\u307f\u308b\u3068\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u307e\u305f\u3041\u307e\u305f\u3041\u3002<\/p>\n<p><strong>\u516c\u5f0f\u30ac\u30a4\u30c9\u30da\u30fc\u30b8<\/strong><\/p>\n<p><a href=\"https:\/\/jp.vuejs.org\/v2\/guide\/typescript.html\" target=\"_blank\" rel=\"noopener\">TypeScript \u306e\u30b5\u30dd\u30fc\u30c8<\/a><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-7730\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/03\/e84fa88ecc630f88dc010bce4128c94c.png\" alt=\"\" width=\"600\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/03\/e84fa88ecc630f88dc010bce4128c94c.png 1504w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/03\/e84fa88ecc630f88dc010bce4128c94c-300x100.png 300w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/03\/e84fa88ecc630f88dc010bce4128c94c-768x255.png 768w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/03\/e84fa88ecc630f88dc010bce4128c94c-1024x340.png 1024w\" sizes=\"(max-width: 1504px) 100vw, 1504px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3061\u3089\u306e\u7d9a\u304d\u3068\u306a\u308a\u307e\u3059\u3002 Vue.js \u304c\u4e88\u60f3\u4ee5\u4e0a\u306b\u826f\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u5b58WordPress\u306b\u5c0e\u5165\u3002Vue.js (vue-class-component) + TypeScript + WordPress \u3067\u4f5c\u308b\u3001\u8a18\u4e8b\u8aad\u307f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[177,168,176,40,166,37,47,179,50,169,173,45,111,39,178,78,114,118],"class_list":["post-7711","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-css3","tag-html","tag-html5","tag-ios-sdk","tag-iphone","tag-iphone-","tag-javascript-2","tag-jquery","tag-jquery-mobile","tag-mac","tag-php","tag-web","tag-wordpress-2","tag-39","tag-178","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7711"}],"version-history":[{"count":20,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7711\/revisions"}],"predecessor-version":[{"id":12629,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7711\/revisions\/12629"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}